Jump to content

Assigning Arrow Key to Decrement


BenD

Recommended Posts

Hi all,

I'm working on a VI that requires a user to decrement a horizontal slider control, and my customer wants the decrement action to be tied to the left arrow key. The arrow keys aren't directly listed in the list of keys that can be bound to the decrement action - are they tied to other keys that are listed, or are they just not available. Page Down seems like the closest thing but they'd really like it to be the arrow key and I agree since it makes the most user-friendly sense. I haven't looked at using an event structure yet to see if I can capture the left arrow value change event, but this seems like a very non-trivial way to do it and I'd think there should be an easier way to map the arrow keys. Any ideas?

- Ben

Link to comment

another easy way to do this is to ensure that the slide has key focus

you can do this through setting the property of the control. You can do this at startup or repeatedly throughout the program, or only when the left key is pressed and then you don't need to worry about if they hold the key down because the control will handle this for you.

Link to comment

QUOTE (ASTDan @ Mar 25 2008, 10:53 AM)

Hello,

I would recomend a Key Down event to handle that. You can then use a case structure that determines what key was pressed. Here is a screen shot.

Dan

Thanks for the replies, folks! Looks like I'm going to be stuck using an event structure, it just mystifies me as to why LV doesn't have the arrow keys as an option for the decrement action. I'll also try the key focus method as well.

- Ben

Link to comment

That's the point, though. In the key binding section of the control properties, you can set page up/down for a specific control, and it will only work for that control. However, you aren't able to do this with the up and down keys. I realize that if you bind up/down to a specific control, then other numerics with increment/decrement would not be able to use the up/down keys when they have focus. But that may be the desired functionality for the program. It's just too bad that LV doesn't allow this, restricting the range of keys that can be unambiuously bound to a specific control.

Link to comment

In my humble opinion using the event structure gives you much more flexiblity i.e you could change the amount you want to increment the control by, put limits on it, change colors, etc.

Also it makes your code a lot easier to read. Everything is in the block diagram not buried somewhere in the property of the control. You are also not limited by what NI decides to give you.

My $.02, or maybe $0.01. If I switch to euros do I get $.03?

Dan

Link to comment

I ended up going with the Key Focus method for simplicity's sake, although I do see the benefits of using the event structure as well. If I need to implement more complex functionality, that will definitely be the way to go!

I also didn't realize that the use of the arrow keys were inferred when the slider control has focus, makes a lot of sense the way Aristos explained it. Thanks for the tips everyone!

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