Page 1 of 1

ListBox (Selection Changed)

PostPosted: Fri Dec 09, 2011 3:48 pm
by TMcD
I'm using a ListBox and when I change the selection by selecting a new one with my cursor, the "Selection Changed" action works.

When I press a button that increments the variable used by the ListBox (the selection) the ListBox visibly changes, but the "Selection Changed" action does not seem to be triggered, which I thought it would be.

I'm not sure what to do. I did try refreshing the ListBox after the variable is incremented, but that does not trigger the "Selection Changed" action.

Again, I would think that incrementing the variable would constitute a "Selection Changed"... ?

Thanks,
Troy

PostPosted: Fri Dec 09, 2011 8:55 pm
by aguilar955
I can not find the problem

Image

Salu2

PostPosted: Fri Dec 09, 2011 9:08 pm
by TMcD
@aguilar955 Thanks for trying to help, but I can't tell if you are showing the actions of a selection change. (I can only see that the variable of the ListBox selection is changing.)

What I see in your animated video is that the variable of the ListBox selection is updated when using a [+] or [-] button, but I can't tell if you have an action being triggered when the selection is changed by a button. (And that is my issue.)

PostPosted: Sat Dec 10, 2011 1:18 am
by dec
Hi,

I'am not sure, but, maybe the "Selection change" event is only fired when the list change... from the list, not from other control like a button. Assuming this, maybe you can take another possibles ways. For example, Suppose you place a "GoSub" action on the "Selection change" event. So the appropiate subroutine is executed. So, maybe is possible to execute the same subroutine from the button that change the listbox. In this way the same subroutine is finally executed.

I hope you can understand my idea. ;)

PostPosted: Sat Dec 10, 2011 1:45 am
by TMcD
Yes, this is what I am wondering as well .... If the ListBox (Selection Change) is only triggered by an actual mouse change in the ListBox.

If that is the case then, that would be disappointing, as a "Selection Change" is a "Selection Change" to me. :)


dec wrote:Hi,

I'am not sure, but, maybe the "Selection change" event is only fired when the list change... from the list, not from other control like a button. Assuming this, maybe you can take another possibles ways. For example, Suppose you place a "GoSub" action on the "Selection change" event. So the appropiate subroutine is executed. So, maybe is possible to execute the same subroutine from the button that change the listbox. In this way the same subroutine is finally executed.

I hope you can understand my idea. ;)

PostPosted: Sat Dec 10, 2011 5:02 am
by Gaev
Troy:
Yes, this is what I am wondering as well .... If the ListBox (Selection Change) is only triggered by an actual mouse change in the ListBox.
Yes ... a mouse or keyboard action ... by a (living breathing) user.

If that is the case then, that would be disappointing, as a "Selection Change" is a "Selection Change" to me.

1) think of it as "a Selection Change by a User" ... as opposed to one triggered by "a change to the Variable: (to store selected item)".

2) No need to be disappointed ... design your Application (for say ListBox1) like so ...

a) copy the current set of commands in the Selection Changed section of the ListBox to a subroutine ... let us call it Variable_Changed_ListBox1 ... make sure to add the Return command at the end of this subroutine.

b) in the Selection Changed section of ListBox1, place the command ...
Code: Select all
GoSub "Variable_Changed_ListBox1"

c) where ever in other parts of your application you had a command like ...
Code: Select all
SetVar "[ListBox1]" "abcd"
... follow it up with a ...
Code: Select all
GoSub "Variable_Changed_ListBox1"

Now, the same set of instructions will be triggered from both types of changes.