vasiliadis Posted August 14, 2012 Report Share Posted August 14, 2012 How can I tell which tab of a tab control was right clicked? Do I have to use the subobj, I can't seem to get any useful information out of that reference. I see that you can also get a coordinates but there is no method to go from the coordinates to the tab that was clicked. Thanks. Quote Link to comment
Mads Posted August 14, 2012 Report Share Posted August 14, 2012 (edited) What functionality are you trying to achieve? Are you are dynamically building shortcut menus for the tab (not the page) that is right-clicked? The value of the control will tell you what page is currently selected, but the selection has to be done with a left-click first...If you right-click on the tab itself and expect a tab specific reaction then tab controls in general (non LabVIEW apps included) will normally not respond to it. So perhaps the best thing is to not build a GUI where the user is expected to do such a thing. You could alternatively place transparent controls above each tab to replace and expand the in-built behaviour, or hide the tabs and just use buttons shaped to look like tabs. Not as elegant as getting the info from the tab control itself, but off the top of my head that's the options I can think of. Edited August 14, 2012 by Mads Quote Link to comment
Ton Plomp Posted August 14, 2012 Report Share Posted August 14, 2012 You can use the mouse-down event so get the coordinates. However to get this working properly you'll need to set the tab-page to fixed: If you cannot live with the tabpages of fixed length, you could detect the width-algorithm that LabVIEW is using by debugging. Using the string-picture VIs you could get some info. Ton Quote Link to comment
Rolf Kalbermatter Posted August 15, 2012 Report Share Posted August 15, 2012 If you cannot live with the tabpages of fixed length, you could detect the width-algorithm that LabVIEW is using by debugging. Using the string-picture VIs you could get some info. That's only a feasable option if you have full control over the font used. If you plan to distribute the app to other computers, even if you are able to control their configuration completely up to what fonts get installed and what fonts LabVIEW defaults to, it's definitely a lot more hassle than you care to ever have. Quote Link to comment
Minh Pham Posted August 16, 2012 Report Share Posted August 16, 2012 We can definately calculate the boundary of an tab label area based on the tab.top and tab.left location plus the tab label width and height. Just abit of simple math, we can specify the area of the right mouse click either it is within the tab label or not. Here is an example on how i can work out the right click is on the tab1 label or not. RightClickOnTabEvent.vi Quote Link to comment
Ton Plomp Posted August 16, 2012 Report Share Posted August 16, 2012 Minh, good catch that the 'FixedTabDimension' does not only return the Fixed tab sizes. I've cleaned up your example with the OpenG Rectangle Tools. (no need to install the OpenG tools to run this example). Of course this could be expanded for different tab arrangements. Ton Quote Link to comment
vasiliadis Posted August 17, 2012 Author Report Share Posted August 17, 2012 Guys, thanks for the response. I'm building an application using the actor framework and I have two tab controllers that manage my receive and transmit windows. I dynamically add pages to the tab, and the user can right click the tab to undock the window so that it floats. That's why I'm trying to figure out which tab the user right clicked on. Thanks. Ton, Could you post your vi so I can test it? Thanks! Quote Link to comment
asbo Posted August 17, 2012 Report Share Posted August 17, 2012 Ton, Could you post your vi so I can test it? Thanks! It's a VI snippet. Save it to your computer and drag it into LabVIEW. Quote Link to comment
vasiliadis Posted August 17, 2012 Author Report Share Posted August 17, 2012 For some reason the VI snippet is showing up as an image. It finally worked, I had to right click and save target. Although I've been using Labview for a long time, I didn't really use snippets before. Thanks. Quote Link to comment
vasiliadis Posted August 17, 2012 Author Report Share Posted August 17, 2012 This doesn't work when you have a page selector, I need that since the user is dynamically adding pages up to 25 windows. However, I am going to use this method to only allow a right click when the user right clicks the selected page. Thanks again to everyone. Quote Link to comment
Jordan Kuehn Posted August 17, 2012 Report Share Posted August 17, 2012 For some reason the VI snippet is showing up as an image. It finally worked, I had to right click and save target. Although I've been using Labview for a long time, I didn't really use snippets before. Thanks. I believe in LAVA the image in a forum post is a thumbnail and you can either 'save target' like you did, or click on the image and then 'save image'. Quote Link to comment
Mads Posted August 20, 2012 Report Share Posted August 20, 2012 This doesn't work when you have a page selector, I need that since the user is dynamically adding pages up to 25 windows. However, I am going to use this method to only allow a right click when the user right clicks the selected page. Thanks again to everyone. If the right-click is only supposed to work if it is on the selected page, do you really need to detect which *tab* was clicked? You can just assume that if the tab control as a whole was right-clicked then that is a right-click on the current page. No need to fiddle with finding out if the user for some reason hit another tab just to not react to it. Any right-click will lead to an action related to the current page. That is probably easier for the user to comprehend than if the right-click in some cases just does not give any response. Again - this would also be consistent with other GUIs - which do not react to right-clicks on tabs, but might have a menu associated with the tab page or control as a whole. Quote Link to comment
Ton Plomp Posted August 20, 2012 Report Share Posted August 20, 2012 Again - this would also be consistent with other GUIs - which do not react to right-clicks on tabs, but might have a menu associated with the tab page or control as a whole. Opera reacts differently for the right mouse button per tab-indicator. Ton Quote Link to comment
Jordan Kuehn Posted August 21, 2012 Report Share Posted August 21, 2012 Opera reacts differently for the right mouse button per tab-indicator. Ton Regardless, there is an established behavior that would make this approach, well, approachable. Quote Link to comment
Mads Posted August 21, 2012 Report Share Posted August 21, 2012 Regardless, there is an established behavior that would make this approach, well, approachable. Personally I would say it's not established enough to be intuitive to the user. But hey, if the users of this particular app expect it to work that way, then that's great. The general rule though should be that if it is possible to implement in a more established way then do that. You can always add a non-standard way as a second option for people to use if they prefer it, but not as the only option. A lot of people have the habit of trying to change GUI behaviour to something "better" - ignoring the fact that the cost of forcing people to change their behaviour from what they know and expect is huge - and seldom worth paying. That's why I asked the question of what the goal with the right-click menu is in this case. If the goal should turn out to be achievable in a more standard way then that should be prioritized over the perhaps "cooler" alternative (Not knowing the use case here the standard way might even turn out to be the coolest). 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.