Jump to content

Toggle Check Box That is In-Focus


Recommended Posts

Hi:

Was checking LabVIEW settings which will allow tabbing to a check-box and toggle TRUE/FALSE value by pressing <RETURN KEY>. :book:

Seems that LabVIEW does not have a way to customize for this. Or perhaps I am missing something? :unsure:

I later found a way to do it in code. :)

Thought I 'd share the code just in-case someone wishes to do the same. :rolleyes:

Note: The idea is to have users quickly fill-in a form with-out having to use the mouse

Anthony

Link to comment

QUOTE(alukindo @ Sep 19 2007, 02:52 AM)

Was checking LabVIEW settings which will allow tabbing to a check-box and toggle TRUE/FALSE value by pressing <RETURN KEY>. :book:

To toggle the true/false value you can right click on the button, go to properties then the Key Navigation Tab and in the toggle section choose "Return" from the drop down list.

You can set the tabbing order of front panel objects by selecting Edit»Set Tabbing Order

Link to comment

Hi Karissap:

Thanks for your suggestion.

However, that setting only allows you to toggle just one check-box. It is not a setting that you can use for multiple check-boxes on a form. In that case all those other check-boxes will not respond to the return key except for the one that you last configured with that setting.

Anthony L.

Link to comment

Why go through all the hassle.. Just use the spacebar when your checkbox has focus..

Besides the fact that you don't have to program it, it is more common user interface behaviour to use the spacebar for that.

QUOTE(tcplomp @ Sep 19 2007, 08:01 AM)

Does anyone know why I get a variant value for a boolean datatype?

I guess it's because your boolean references are not strictly typed.. LabVIEW has no way of knowing whether the booleans you register dynamically have a mechanical action of switch or latch.

Link to comment

QUOTE(Jeffrey Habets @ Sep 19 2007, 09:41 AM)

Why go through all the hassle.. Just use the spacebar when your checkbox has focus..

Besides the fact that you don't have to program it, it is more common user interface behaviour to use the spacebar for that.

I guess it's because your boolean references are not strictly typed.. LabVIEW has no way of knowing whether the booleans you register dynamically have a mechanical action of switch or latch.

Yes I know that, but it should not matter, the data-type should be boolean wheter it's a latch or switch (right?)

A latch should fire an error if the wrong boolean type is used.

I propose two have two boolean reference types:

  • Switch
  • Latch

Ton

Link to comment

QUOTE(tcplomp @ Sep 19 2007, 10:16 AM)

I guess making the Value a variant is NI's way of saying: watch it, there's something special going on here.. You're actually not allowed to use the Value* properties for reading or writing a boolean that is in latch mode. If you try it, you'll get an error..

QUOTE(tcplomp @ Sep 19 2007, 10:16 AM)

I propose two have two boolean reference types:
  • Switch

  • Latch

Ton

Yes, that would be nice.. But as it is now, there's only one boolean object with an attribute that lets it behave in different modes (instead of using inheritance hierarchy of various boolean controls), thus only one reference..

As a workaround to get strict types you could cast to a reference linked to one of the checkboxes like this:

post-906-1190203262.gif?width=400

You could also filter the array of controls by looking at the Mechanical Action (private) property to makes sure you only get refs to the right controls.

Link to comment

QUOTE(Jeffrey Habets @ Sep 19 2007, 02:03 PM)

Yes, that would be nice.. But as it is now, there's only one boolean object with an attribute that lets it behave in different modes (instead of using inheritance hierarchy of various boolean controls), thus only one reference..

I've been thinking a little about this, what you expect is a read-only 'value' property for latches and a read/write for switches.

But there's an issue. Value is a property of the 'Control' class... and not of a '...... Control'. So the Boolean latch class should disable the write property of a Control.

And using a the 'dynamic casting' as you showed force me to use two event cases with the same contents.

Ton

Link to comment

QUOTE(tcplomp @ Sep 19 2007, 02:19 PM)

I've been thinking a little about this, what you expect is a read-only 'value' property for latches and a read/write for switches.

But there's an issue. Value is a property of the 'Control' class... and not of a '...... Control'. So the Boolean latch class should disable the write property of a Control.

And using a the 'dynamic casting' as you showed force me to use two event cases with the same contents.

I don't understand why you would need two event cases.. In this particular case we are only interested in checkboxes, and I expect these to be in switch mode, not latch..

For latch mode your event code would be of no use anyway since reading/writing of the boolean value property is not possible. So, just wire the array of strict bool-refs to the RegEvents node and you can handle all switch booleans in one event case.

Link to comment

QUOTE(Jeffrey Habets @ Sep 19 2007, 03:41 AM)

Why go through all the hassle.. Just use the spacebar when your checkbox has focus.

Hi Habets:

Thanks!

I actually tested a number of keyboards presses including shift enter but MISSED the space bar. Now I can remove the code from the form. It is not needed at all.

Again thank you for pointing this out. :thumbup:

Anthony

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.