Jump to content


Photo
- - - - -

Event Structure Firing Order

event structures dataflow

  • Please log in to reply
6 replies to this topic

#1 for(imstuck)

for(imstuck)

    Very Active

  • Members
  • PipPipPip
  • 152 posts
  • Location:Texas
  • Version:LabVIEW 2012
  • Since:2008

Posted 09 April 2012 - 05:07 PM

I have a multicolumn listbox where I would like a "right-click" to set the value of the MC listbox to the row that was right-clicked, then a shortcut menu will appear. Depending on the value of the MC listbox (i.e. row clicked) I determine what right-click menu options are available. To do this, I use the mouse down event, and if it's a right click, I set the MC listbox value to the row clicked. Then, the shortcut menu activation event is fired, and in there I use the current value of the MC listbox to enable/disable menu items. My question is this, can I always expect the mouse down event to occur first (it seems it does), or do I need to manage the order in which the events fire. I guess I could also handle all this logic in the mouse down case, inside my case structure, when checking which button was pressed. What I want to make sure I avoid is the shortcut menu activation firing first and having the wrong row selected in the MC listbox which may disable/enable the wrong menu items.

Edit:
After discussing w/ co-workers, I think the answer is yes, because the mouse-down is the event, the shortcut menu activation is the system response to that event. Please let me know if this is wrong.

Edited by for(imstuck), 09 April 2012 - 05:07 PM.

CLA (but still always learning)

#2 asbo

asbo

    I have no idea what you're talking about... so:

  • V I Engineering, Inc.
  • 1,273 posts
  • Version:LabVIEW 2011
  • Since:2008

Posted 12 April 2012 - 04:57 PM

I agree with your conclusion. I don't think these can ever be out of order because LV has to recognize the click (Mouse Down) before it can react (Shortcut Menu).

Off topic, but shouldn't your username be while(imstuck)? Is imstuck iterable?

#3 Darin

Darin

    Very Active

  • Members
  • PipPipPip
  • 168 posts
  • Version:LabVIEW 2009
  • Since:1992

Posted 12 April 2012 - 05:34 PM

If it keeps you up at night you could use the Mouse Down? filter event, but I also think that both events are handled before the short menu activiation. Furthermore, I have found that in situations like this the behavior is at least consistent, meaning that it either works or it doesn't. It sounds like it worked, so if it were me I would not worry that much about it.

#4 Aristos Queue

Aristos Queue

    LV R&D: I write C++/# so you don't have to.

  • Premium Member
  • 2,643 posts
  • Location:Austin, TX
  • Version:LabVIEW 2011
  • Since:2000

Posted 13 April 2012 - 02:24 AM

Yes, those events will always come in the predictable order, as asbo postulated.

asbo: Never forget that "for" can be abused as "while" in a lot of C-like languages. Read it as "for(;imstuck;)" where imstuck is true. Semicolons would be needed in C++, but there are other similar languages where you wouldn't need them.

#5 asbo

asbo

    I have no idea what you're talking about... so:

  • V I Engineering, Inc.
  • 1,273 posts
  • Version:LabVIEW 2011
  • Since:2008

Posted 13 April 2012 - 12:19 PM

Makes me wonder if we're allowed semicolons in our usernames...

#6 for(imstuck)

for(imstuck)

    Very Active

  • Members
  • PipPipPip
  • 152 posts
  • Location:Texas
  • Version:LabVIEW 2012
  • Since:2008

Posted 13 April 2012 - 03:21 PM

Yes, those events will always come in the predictable order, as asbo postulated.

asbo: Never forget that "for" can be abused as "while" in a lot of C-like languages. Read it as "for(;imstuck;)" where imstuck is true. Semicolons would be needed in C++, but there are other similar languages where you wouldn't need them.

Makes me wonder if we're allowed semicolons in our usernames...


:D ...although, this actually stops fairly quickly.

Attached Thumbnails

  • stuck.png

Edited by for(imstuck), 13 April 2012 - 03:22 PM.

CLA (but still always learning)

#7 Ravi Beniwal

Ravi Beniwal

    Very Active

  • Premium Member
  • 88 posts
  • Location:Detroit
  • Version:LabVIEW 2011
  • Since:2001

Posted 21 April 2012 - 06:06 PM

The Mouse Down? filter event is usually a better choice (at least in my experience), because it let's you discard the menu activation or any other processing, if the right click happened to be on the column headers, or on an empty row.





Also tagged with one or more of these keywords: event structures, dataflow