BenD Posted March 26, 2008 Report Share Posted March 26, 2008 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 Quote Link to comment
ASTDan Posted March 26, 2008 Report Share Posted March 26, 2008 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 Quote Link to comment
Norm Kirchner Posted March 26, 2008 Report Share Posted March 26, 2008 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. Quote Link to comment
BenD Posted March 26, 2008 Author Report Share Posted March 26, 2008 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 Quote Link to comment
Norm Kirchner Posted March 26, 2008 Report Share Posted March 26, 2008 QUOTE t just mystifies me as to why LabVIEW doesn't have the arrow keys as an option for the decrement action. But it does... the control just needs to have the key focus Quote Link to comment
Aristos Queue Posted March 26, 2008 Report Share Posted March 26, 2008 QUOTE (Norm Kirchner @ Mar 25 2008, 01:23 PM) But it does... the control just needs to have the key focus The reason it has to have focus is because otherwise it is ambiguous which numeric on the front panel you want LabVIEW to decrement. Quote Link to comment
Yuri33 Posted March 26, 2008 Report Share Posted March 26, 2008 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. Quote Link to comment
ASTDan Posted March 26, 2008 Report Share Posted March 26, 2008 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 Quote Link to comment
BenD Posted March 26, 2008 Author Report Share Posted March 26, 2008 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! 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.