|
Larkin Wizard
Joined: 25 Mar 2003 Posts: 1113 Location: USA
|
Posted: Fri May 02, 2008 2:53 pm
[2.23] onLoad ignores class scope for creating buttons |
I'm using the onLoad event to create settings, based on other installed or configured options, and it works great for variables but not for buttons. My buttons are always created in my main package, outside of any window or module. I've tried using #CLASS "//Module Name/GUI" before the #BUTTON command and also just putting the class folder directly in the #BUTTON command.
|
|
|
|
Larkin Wizard
Joined: 25 Mar 2003 Posts: 1113 Location: USA
|
Posted: Mon May 05, 2008 8:12 pm |
This is a sort of a bump because I don't think this should go unfixed for the public release, but I do have a little bit to add to it...
I have a brand new session and a package previously created in another session. When I load the package, it creates the buttons in the tree view for the main session package. They're displayed in the folder in the correct package when I select the "GUI" folder in that module, but the folder there has no child items to see. So, something's definitely out of sync in the PE.
I closed the session and re-opened it. This time, the buttons have been made child items of random variables in my main session package. This was something I reported a long while back and it was dismissed as a corrupt package from a previous version, but this package was built fresh in 2.23 and the issue now is either with the PE or the onLoad creation of the buttons.
The XML for the variable/button combo ends up looking like this:
Code: |
<var name="current_credits" id="30">0
<button name="btnstance" autosize="false" width="140" height="20" toolstyle="true" transparent="false" color="black" textcolor="silver" gaugelowcol="red" gaugebackcol="#E0DFE3" priority="512" id="69">
<caption>stance</caption>
<value>i_auto stance none;i_checkstance</value>
</button>
</var> |
I tried to "correct" the mistake by removing the offending button in the XML, except that clicking the Save button puts it right back again! Using Cut/Paste in the treeview works, however. |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Mon May 05, 2008 9:03 pm |
So what is the exact script in the onLoad event that is creating the #BUTTON. Give me a specific example for reproducing this. If it's going to get fixed for the public version on Wednesday, then I must have a procedure for making it happen. Not a lot of time between now and then. So the easier you can make this for me, the better the chance of getting it fixed.
|
|
|
|
Larkin Wizard
Joined: 25 Mar 2003 Posts: 1113 Location: USA
|
Posted: Tue May 06, 2008 11:17 am |
1. Open a blank new session to test.
2. Open PE.
3. File -> New Package -> name it Test
4. In the new package, create onLoad event with the following code in it:
Code: |
#IF (!%btnenable("btnstance")) {
#CLASS "//Test/GUI"
#BUTTON 0 {stance} {i_auto stance none;i_checkstance} {} {} {} {} {} {Size} {140} {20} {} {} {} {8} {} {} {} "" {Explore} {} {btnstance}
#CALL %priority("btnstance", button, 512)
#CLASS 0
}
|
5. Save package and then remove it from the session.
6. File -> Open -> Test.pkg
When I did this procedure just now, I got both the crash and the errant button. |
|
|
|
Larkin Wizard
Joined: 25 Mar 2003 Posts: 1113 Location: USA
|
Posted: Wed May 07, 2008 2:15 pm |
Any luck reproducing and/or fixing this one yet, Zugg?
|
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Wed May 07, 2008 4:30 pm |
It's on my list for today. Stay tuned.
|
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Wed May 07, 2008 8:10 pm |
This must have been related to one of the other bugs that I've already fixed, because it's working fine for me in v2.24. Using your example, I get a button created in the //Test/GUI folder just like it should. No crashes and no problems whether I load the session again, or whether I remove the package and then reload it.
If you still get this problem in v2.24, try deleting your DEFAULT.PKG file in case it is corrupted from a previous version. |
|
|
|
Larkin Wizard
Joined: 25 Mar 2003 Posts: 1113 Location: USA
|
Posted: Wed May 07, 2008 8:56 pm |
Okay. Sounds good. I'll let you know what I find in 2.24 then.
|
|
|
|
Larkin Wizard
Joined: 25 Mar 2003 Posts: 1113 Location: USA
|
Posted: Thu May 08, 2008 9:51 am |
Still bugged for me in 2.24. The button appeared to be in the //Treant Stance/GUI class when I selected the class in the tree view and looked at the list on the right, but the tree view actually showed it in the Lusternia module as a root node again. Also, the btn_stance +1 alarm that I created in the //Treant Stance/GUI class folder was enabled and not firing (it, too, was created by the onLoad event).
I cut/paste'd the button to get it into the right folder again, then forced the alarm to fire before manually deleting it. Now, when my module loads and uses the %btnenable(btnstance) to see if the button exists before creating it, it goes ahead and creates a duplicate button, anyway.
Procedure to re-create it (minus the alarm issue, which eludes me now):
1. Use untitled session.
2. Open PE, use File -> New Package -> name Test.
3. In Test package, paste the following XML:
Code: |
<class name="Events" id="1">
<event event="onLoad" priority="20" id="2">
<value>#IF (!%btnenable("btntest")) {
#CLASS "//Test/GUI"
#BUTTON 0 {test} {#SAY Testing} {} {} {} {} {} {Size} {140} {20} {} {} {} {8} {} {} {} "" {Explore} {} {btntest}
#ALARM "btn_test" +1 {
#SAY "Button created"
}
#CALL %priority("btntest", button, 512)
#CLASS 0
}
</value>
</event>
</class>
|
4. Save package before right-clicking and deleting the Test tab.
5. File -> Open -> Test.pkg.
Button will be in the untitled tab's settings, but it appears in the GUI class XML.
P.S. I deleted the package from the session a second time and re-opened it, causing a crash in CMUD. Also, note that all of this happened in a single session instance. After I closed CMUD and opened the package in the untitled session again, the button was created perfectly. |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Thu May 08, 2008 5:26 pm |
OK, now this is crashing for me too. Dammit, this is the same damn bug that I spent three hours on yesterday. I can't understand why it is still happening. It's driving me crazy!
And yes, it's creating the button in the top level where it never should, and that will cause a lot of problems. |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Thu May 08, 2008 6:36 pm |
OK, this might be a bit serious. Turns out that the #CLASS command was not creating the class properly.
When the context is set to the main untitled window (like when running the onLoad event), the command
#CLASS //ModuleName/ClassName
doesn't create the class correctly if "ModuleName" is in a different package from the current context (the untitled window). Even though it looked like the GUI class was created properly, it actually had screwed up pointers. It's "Parent" field was properly set to the Test module (which is why it displays correctly in the settings editor), but it's "Module" field was set to "untitled" instead.
Then, when the button was created within this messed up class, the button itself was messed up.
This is fixed in 2.25 I hope. It was worthy of an emergency fix because the problem wasn't actually creating the button, but was with the #CLASS command not creating classes properly, and that is much more serious. |
|
|
|
|
|