Can't get the control panel to appear on screen if I click it in the icon bar. Would I start with this:
function btnControlPanel_Click(GUIControl *control, MouseButton button)
but what's the right command for "gPanel" to show and work correctly?
Just turn it visible:
gPanel.Visible = true;
Hi
I'm assuming you are not customising the gIconbar and are using it normally.
if you have not touched any scripting and the gIconbar is visible then you should only have to click on the ? button on the right of the gIconbar, else press Escape key to bring it up.
You don't normally have to touch anything.
Not sure what else it could it be..
barefoot
Yes, if you have set it as invisible..
barefoot
Nope, I modified the icon bar to have 10 icons, I removed the ? and have a picture of sliding bars resembling a control panel. But I'll give Khris's line a whirl and see if that works.
Argh! Didn't work. Here's what I put in:
function btnControlPanel_Click(GUIControl *control, MouseButton button) {
gPanel.Visible=true;
}
Still does nothing if I click it. Works if I hit Escape though.
Hi
Just on case you messed up here is the original script.
The gIconbar ? (image) events button is btnIconAbout.. when you click it:
gPanel.Visible=true;
gIconbar.Visible=false;
mouse.UseModeGraphic(eModePointer);
barefoot
In that case it sounds like the button's function isn't linked properly.
Usually you'd simply double-click the button after creating it, this creates the function and links it.
Open the Iconbar GUI, select the control panel button, then click the lightning icon. Below that it should say "OnClick" and next to it: "btnControlPanel_Click".
That's how AGS knows to call the function upon a click on the button.
Quote from: barefoot on Sun 22/05/2011 21:38:30
Hi
Just on case you messed up here is the original script.
The gIconbar ? (image) events button is btnIconAbout.. when you click it:
gPanel.Visible=true;
gIconbar.Visible=false;
mouse.UseModeGraphic(eModePointer);
barefoot
I deleted the About button because I don't feel like re-scaling my inventory buttons and it's not necessary for gameplay. My button is labelled btnControlPanel.
Quote from: Khris on Sun 22/05/2011 21:56:34
In that case it sounds like the button's function isn't linked properly.
Usually you'd simply double-click the button after creating it, this creates the function and links it.
Open the Iconbar GUI, select the control panel button, then click the lightning icon. Below that it should say "OnClick" and next to it: "btnControlPanel_Click".
That's how AGS knows to call the function upon a click on the button.
I thought that was the problem too but when I go into the Iconbar window and get to the control panel button, then click Events, the "btnControlPanel_Click" box leads me to the first few lines of code in the main global script file. Do I just put that same code, linked correctly, somewhere below that?
If it takes you to the function with "gPanel.Visible = true;" inside, everything should work fine.
I don't know why it still won't work, but to be really sure, put this before the Visible line:
Display("Test.");
If you click the button, does it display that? Also, please post the entire function you currently have.
There's this function that doesn't seem to do anything under "Start of Control Panel Functions":
function gControl_OnClick(GUI *theGui, MouseButton button)
{
gPanel.Visible = true;
mouse.UseDefaultGraphic();
gIconbar.Visible = false;
}
Here's what I tried using that does absolutely nothing despite clicking on the correctly-labelled icon bar button:
function btnControlPanel_OnClick(GUIControl *control, MouseButton button)
{
gPanel.Visible = true;
mouse.UseDefaultGraphic();
gIconbar.Visible = false;
}
What am I doing wrong??? I really don't understand. The freakin button is properly labeled.
Like I said, make sure the function is called. Read my previous post.
Solved it!
Here's the utterly stupid and obvious thing I missed...
That damn lightning bolt button. I just had it as "btnControlPanel", not "btnControlPanel_OnClick". That and I realized with the last 10 times I hit F5 to try out other scripting aspects, just HOW crucial it really is to go through that Event button first. Doesn't matter if you script first or after hitting it, but I'm hitting it first from now on so I don't get confused. And my script was correct, just wrong label. Definitely leave this here for other beginners with the same problem though.
And now that I see the control panel I designed pop up on screen....yeesh I need to scale that thing down.
Since you didn't get an error message, there's a function called btnControlPanel somewhere in your script. Better get rid of it to avoid future confusion.
Nope, only one is btnControlPanel_OnClick. I think it was mislabelled in the Events window the entire time.
You're right, I just tested it and didn't get an error.
It still throws an error for missing room functions though, but apparently not for missing OnClick ones.
I got TONS of errors when the stuff in the rooms didn't match up-- whereas it didn't create a fatal error for the control panel one, the icon just didn't work. I got it to work correctly now though.