Button Sequence Called Twice (Changing Page.strcurrentpage)

Recommended Posts

I was coding a quick sequence that modifies Page.strCurrentPage in a button component (5.87c).  I found that the quick sequence can be called twice if the button's page is part of the new Page.strCurrentPage list.  In my case, I was trying to use a button to toggle between "Page_0" and "Page_1,Page_0" where Page_0 is my main page and Page_1 is a help panel.


It seems that the click event for the Button on Page_0 is passed though again to the same Button immediately after changing to the new merged Page_1,Page_0 pages (similar to how stacked components like panels under symbols can get clicks in the stack.)


I have attached an example showing the issue.  Monitor the command window for output with each button press.  If you press the 'Page_0' (top) button, then Page_0 is set and emits "Page_0".  If you then press the 'Page_1,Page_0' (middle) button, it merges the pages but calls the button event twice which emits "Page_1,Page_0" twice. 


Order is important, since pressing 'Page_0' (top) followed by 'Page_0,Page_1' (bottom) button does not pass the event twice.


Any tips on preventing this effect since I intended to use the button to 'toggle' the page changes?  Calling a sequence that does the change seems to help because the sequence is already running when the second event attempts to begin the sequence again...however, could the sequence run fast and allow the extra event to pass though sometimes?  Maybe I could set a flag in a quick button sequence with the 'On Mouse Down' checkbox set, and then use that flag for another normal quick sequence in the button.  Other ideas?  Thanks for you time.



Link to comment
Share on other sites

OK, here's the long answer: click events are passed to all components at the location of the mouse, which, as you indicated allows commands to pass to stacked components.  The system runs through a for loop of the current pages.  If the button is on the first page of the list of current pages, that list of current pages changes and when the loop iterates, if you've added a page to the current page list, instead of stopping, it processes the event for the added page.


I have two recommendations:

1) I'm assuming you are going to make a menu that is always displayed.  Put it last in the page list.  Like you noted, order matters.

2) You actually should be careful about putting buttons that do different things in the same location of the page.  The reason for this is that even without this little "feature" of DAQFactory, operators often accidentally double click, especially on touch screens.  I'm sure you've done it at some point where you click a button to popup a window, and it happens the Cancel or OK button for the popup comes up in the same place and you inadvertantly immediately close the popup.  I always try and design it so page change buttons don't change to a page where there is a click action in the same area of the screen.

Link to comment
Share on other sites

Thanks for your detailed reply and design tips.


Regarding (1), I do have a menu but it's in the main page.  I can change the menu to its own page and always have it last so the button only changes pages above.  In this instance the menu was on the main page and I was trying to have one of the 'menu' buttons toggle a 'help' panel over part of that page.  I did not put any components in the 'help' panel (including a close button) since, as you mention, clicks might pass through to the page below.  I could use a 'hidden' panel and have the menu button make it visible/hidden.  Of course, I could also use an actual popup window too.  Thanks for your tips.


Regarding (2), thanks for the double-click reminder...you are correct.

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.