Jump to content

Tab control - right click menu


Recommended Posts

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.

Link to comment

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
Link to comment

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:

post-2399-0-99105300-1344955598.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

Link to comment

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.

Link to comment

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.

post-11757-0-51106700-1345081781_thumb.p

RightClickOnTabEvent.vi

Link to comment

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

post-2399-0-50950700-1345098835_thumb.pn

Of course this could be expanded for different tab arrangements.

Ton

Link to comment

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!

Link to comment

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.

Link to comment

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

Link to comment

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.

Link to comment

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

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.