Jump to content


Photo
- - - - -

Tab control - right click menu


  • Please log in to reply
14 replies to this topic

#1 vasiliadis

vasiliadis

    Enough LAVA to be dangerous

  • Members
  • 4 posts
  • Location:Jorge Ignacio Vasiliadis
  • Version:LabVIEW 2009
  • Since:2002

Posted 14 August 2012 - 01:27 PM

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.

#2 Mads

Mads

    Very Active

  • Members
  • PipPipPip
  • 171 posts
  • Location:Bergen, Norway
  • Version:LabVIEW 2012
  • Since:1997

Posted 14 August 2012 - 02:37 PM

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 by Mads, 14 August 2012 - 02:40 PM.

MTO

#3 Ton Plomp

Ton Plomp

    How many lines per hour? Zero!

  • Premium Member
  • 1,971 posts
  • Location:Netherlands
  • Version:LabVIEW 2012
  • Since:2000

Posted 14 August 2012 - 02:47 PM

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:

Example_VI_BD.png

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

#4 rolfk

rolfk

    LabVIEW Aficionado

  • Premium Member
  • 2,045 posts
  • Location:Netherlands
  • Version:LabVIEW 2011
  • Since:1992

Posted 15 August 2012 - 08:03 AM

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.

#5 Minh Pham

Minh Pham

    Very Active

  • Members
  • PipPipPip
  • 167 posts
  • Location:Sydney
  • Version:LabVIEW 2010
  • Since:2006

Posted 16 August 2012 - 01:50 AM

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.

Attached Thumbnails

  • rightclickonTabEvent.png

Attached Files


>>>> Stop coding >>> Start Wiring >>>>

#6 Ton Plomp

Ton Plomp

    How many lines per hour? Zero!

  • Premium Member
  • 1,971 posts
  • Location:Netherlands
  • Version:LabVIEW 2012
  • Since:2000

Posted 16 August 2012 - 06:34 AM

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).
RightClickOnTabEvent_BD.png

Of course this could be expanded for different tab arrangements.

Ton

#7 vasiliadis

vasiliadis

    Enough LAVA to be dangerous

  • Members
  • 4 posts
  • Location:Jorge Ignacio Vasiliadis
  • Version:LabVIEW 2009
  • Since:2002

Posted 17 August 2012 - 06:16 PM

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!

#8 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 17 August 2012 - 06:20 PM

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.

#9 vasiliadis

vasiliadis

    Enough LAVA to be dangerous

  • Members
  • 4 posts
  • Location:Jorge Ignacio Vasiliadis
  • Version:LabVIEW 2009
  • Since:2002

Posted 17 August 2012 - 06:31 PM

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.

#10 vasiliadis

vasiliadis

    Enough LAVA to be dangerous

  • Members
  • 4 posts
  • Location:Jorge Ignacio Vasiliadis
  • Version:LabVIEW 2009
  • Since:2002

Posted 17 August 2012 - 06:57 PM

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.

#11 Jordan Kuehn

Jordan Kuehn

    Very Active

  • Premium Member
  • 220 posts
  • Location:Oklahoma
  • Version:LabVIEW 2011
  • Since:2009

Posted 17 August 2012 - 08:16 PM

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'.
The Colex Group
Lead Software Engineer
Certified LabVIEW Developer

#12 Mads

Mads

    Very Active

  • Members
  • PipPipPip
  • 171 posts
  • Location:Bergen, Norway
  • Version:LabVIEW 2012
  • Since:1997

Posted 20 August 2012 - 09:03 AM

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.
MTO

#13 Ton Plomp

Ton Plomp

    How many lines per hour? Zero!

  • Premium Member
  • 1,971 posts
  • Location:Netherlands
  • Version:LabVIEW 2012
  • Since:2000

Posted 20 August 2012 - 06:10 PM

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

#14 Jordan Kuehn

Jordan Kuehn

    Very Active

  • Premium Member
  • 220 posts
  • Location:Oklahoma
  • Version:LabVIEW 2011
  • Since:2009

Posted 21 August 2012 - 05:40 AM

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.
The Colex Group
Lead Software Engineer
Certified LabVIEW Developer

#15 Mads

Mads

    Very Active

  • Members
  • PipPipPip
  • 171 posts
  • Location:Bergen, Norway
  • Version:LabVIEW 2012
  • Since:1997

Posted 21 August 2012 - 07:13 AM


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).
MTO