|
makena Apprentice
Joined: 11 Aug 2006 Posts: 100
|
Posted: Sat Mar 15, 2008 9:53 am
[2.20] Buttons/Variables not working correctly |
Opened cmud, created two new sessions (test1 and test2), opened both offline.
Created a package (testpack), shared it with both sessions.
In the package, created a variable (testvar) and a button.
The button has @testvar as the caption.
The button is displayed on both windows, yay! (i always was looking forward to that improvement)
But if you enter the following in the command line on one session:
the button only updates in the window with focus.
switch back to the other session and the button has not updated. |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Mon Mar 17, 2008 5:09 pm |
That is actually a known bug (not that you would have any way to know that). When using shared buttons with a shared variable, only the caption of the window with focus is updated right now, sorry.
|
|
|
|
makena Apprentice
Joined: 11 Aug 2006 Posts: 100
|
Posted: Mon Mar 17, 2008 5:51 pm |
The problem affects not only shared buttons, but all buttons.
I will have to wait untill April/May for a fix? or longer? |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Mon Mar 17, 2008 8:39 pm |
It should only effect buttons that are defined in a separate module (which are called "shared buttons"). If the button and variable are created within the specific window that you want them, then it works fine for me here.
I don't give timescale or release dates for specific versions or bug fixes, sorry. |
|
|
|
makena Apprentice
Joined: 11 Aug 2006 Posts: 100
|
Posted: Wed Mar 19, 2008 5:34 pm |
Zugg wrote: |
It should only effect buttons that are defined in a separate module (which are called "shared buttons"). If the button and variable are created within the specific window that you want them, then it works fine for me here.
|
This is incorrect, not only are "shared buttons" effected.
Create two sessions, one with a button/variable.
Set the caption of the button, to the variable.
If you change the variable's contents from the second session, the button will not update correctly.
Yes, the button updates correctly if you change the content of the variable from within the same session (like you said)!
The problems arises when the variable is updated from the OTHER session, regardless if the button is "shared" or not. |
|
|
|
Larkin Wizard
Joined: 25 Mar 2003 Posts: 1113 Location: USA
|
Posted: Wed Mar 19, 2008 5:52 pm |
All I know is that my buttons with variable captions worked pretty well in 2.18 and now in 2.20 they're kinda hit-or-miss.
|
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Wed Mar 19, 2008 8:05 pm |
Quote: |
If you change the variable's contents from the second session, the button will not update correctly. |
How *exactly* are you changing the first windows variable from within the second session? Variables are local/private to a window and cannot normally be accessed from another window. |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Wed Mar 19, 2008 9:34 pm |
I believe makena is saying that if you have 2 windows, 1 button, and 1 variable in a shared module; then it doesn't work correctly when the window that doesn't have a button changes the variable. In fact I have seen this and put something in my toolbox to get around it.
Procedure
1. Launch CMud
2. Close Sessions Window (ESC)
3. Enter at the command line
Code: |
#MODULE b;#VAR abc {1};#WIN a;#MODULE a;#BUTTON 1 "@abc" {};#MODULE 0 |
4. Enter at the command line
As you will see the button did not update. I use 2 different work arounds for this in my Toolbox package. One is putting a function in the status bar that updates a window only variable when the others are changed. This is because status bars seem to properly detect that type of shared variable change. The other work around I use is to #FIRE a trigger in the button window that forces an update by changing that second variable. |
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
|
makena Apprentice
Joined: 11 Aug 2006 Posts: 100
|
Posted: Thu Mar 20, 2008 5:06 am |
Vijilante is correct. If you follow his example, and enter 'abc=whatever' on the command line of each window, the variable updates correctly from each command line. But, the button only updates when the variable change occurs in the same window as the button. This is not just a "shared button" problem :(
Vijilante: Thanks for figuring out what I was trying to say. Can you send me or post more on how you worked around this issue? |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Thu Mar 20, 2008 5:12 am |
The idea is that you have two separate variables for each button and just update them separately, at the same time. You do that by firing a trigger in the second window with #fire that'll update the variable in the other window.
The function method is a bit more complex - you'd want to have three variables, one shared and one in each window. The buttons for each window use the variable in that window. You update the shared variable as you would if the bug wasn't there, and add this code to the status line of each window:
@ButtonSetFunc(@SharedVariable,"localvariablename")
where "localvariablename" is the name of the varibale in the window you want to update. Then the function does something like:
#func ButtonSetFunc {#var %2 %1;#return ""}
Because the @SharedVariable is present in the status line, the status line will be checked every time it changes and run the code in your function. That, in turn, will update the local variables in the windows, which then causes the buttons to be repainted. The #return "" is to make the ButtonSetFunc not make any difference to the appearance of your status line. |
|
|
|
|
|