Graeme Posted January 5, 2008 Report Share Posted January 5, 2008 Hi all, I have a Listbox for a user to input numerous strings at run-time (lists of recipients for one of the SMTP VIs). Double-click allows editing of a row. Right-click brings up a user menu, some of whose selections are row dependant. Thus, I have to calculate (albeit simply) in which row the mouse pointer was when the menu was brought up. It seems to work. I have two questions regarding this technique, though, both vaguely related, although only one is LabVIEW, the other is OS. First, LabVIEW. In the Listbox event "Shortcut Menu Selection (User)" there is available the reference "SubObj". I'd hoped that this might be a reference to the row where the menu was brought up, thus sparing me the maths. However, although I can wire this reference to various nodes, they all produce the run-time error "Object reference is invalid". I can't do anything with it. Can someone tell me what this refrence is and how it should be used? Second, a right click on an object in an OS (say a folder): does the OS return a reference to the object or do you still have to calculate the mouse pointer position to determine which object has been clicked on? I'm really looking for best practice techniques to employ in LabVIEW, where available. I attach my listbox VI. Regards, Graeme, Quote Link to comment
JDave Posted January 5, 2008 Report Share Posted January 5, 2008 QUOTE(Graeme @ Jan 4 2008, 02:14 PM) I have a Listbox for a user to input numerous strings at run-time (lists of recipients for one of the SMTP VIs). Double-click allows editing of a row. Right-click brings up a user menu, some of whose selections are row dependant. Thus, I have to calculate (albeit simply) in which row the mouse pointer was when the menu was brought up. It seems to work.I have two questions regarding this technique, though, both vaguely related, although only one is LabVIEW, the other is OS. First, LabVIEW. In the Listbox event "Shortcut Menu Selection (User)" there is available the reference "SubObj". I'd hoped that this might be a reference to the row where the menu was brought up, thus sparing me the maths. However, although I can wire this reference to various nodes, they all produce the run-time error "Object reference is invalid". I can't do anything with it. Can someone tell me what this refrence is and how it should be used? Second, a right click on an object in an OS (say a folder): does the OS return a reference to the object or do you still have to calculate the mouse pointer position to determine which object has been clicked on? I'm really looking for best practice techniques to employ in LabVIEW, where available. I attach my listbox VI. Regards, Graeme, [0] I believe starting in LV 8.0(?) you can just use a method on the listbox to retrieve the clicked row (and column) using the mouse coordinates. [1] SubObj refers to the control actually clicked on. May be a member of a cluster. http://zone.ni.com/reference/en-XX/help/371361D-01/lvprop/vi_shrtct_menu_activation/' target="_blank">See here. [2] The OS doesn't return anything to LabVIEW. I am not sure what you are referring to here. You can poll the mouse for movement and clicks, but you will not receive any event notifications from mouse events that occur outside LabVIEW windows. David Quote Link to comment
Graeme Posted January 5, 2008 Author Report Share Posted January 5, 2008 Hi JDave, Thanks for the prompt response. [0] Looking into it. [1] That's what I thought, but it doesn't do it for me. I'll investigate further, particularly your link, thanks (although the list box looks like an array to me, not a cluster - willing to be corrected) [2] Very badly worded question on my part, and I shouldn't've asked it here. I know the OS doesn't return to LV, but I just wondered if, say, Windows, programmers had to calulate a right-click event, do they have to work out co-ordinates or do they simply get returned a reference to the right-clicked control automatically? Idle curiosity, really. Thank you again JDave. Quote Link to comment
JDave Posted January 5, 2008 Report Share Posted January 5, 2008 QUOTE(Graeme @ Jan 4 2008, 03:09 PM) Hi JDave,Thanks for the prompt response. [0] Looking into it. [1] That's what I thought, but it doesn't do it for me. I'll investigate further, particularly your link, thanks (altough the list box looks like an array to me, not a cluster - willing to be corrcted) [2] Very badly worded question on my part, and I shouldn't've asked it here. I know the OS doesn't return to LV, but I just wondered if, say, Windows, programmers had to calulate a right-click event, do they have to work out co-ordinates or do they simply get returned a reference to the right-clicked control automatically? Idle curiosity, really. With regards to [1], the SubObj only applies to objects that do have sub-objects -- such as clusters. Quote Link to comment
Ton Plomp Posted January 6, 2008 Report Share Posted January 6, 2008 QUOTE(JDave @ Jan 4 2008, 11:38 PM) [0] I believe starting in LV 8.0(?) you can just use a method on the listbox to retrieve the clicked row (and column) using the mouse coordinates. QUOTE(Graeme @ Jan 5 2008, 12:09 AM) [0] Looking into it. Here's a post containing the variaous 'mouse to xxxx' methods http://lavag.org/old_files/monthly_12_2006/post-2399-1166287302.png' target="_blank"> Ton Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.