Search the Community
Showing results for tags 'hotkeys'.
Found 2 results
-
I have a hotkey config dialog which responds to key presses by jumping to that key in a list and focusing it for editing. The user must first press "Find Key" and then select a key in order to edit it (but, I'm seriously considering removing this button altogether and just have the dialog always listen for key presses). Problem is, if they hit [Space], this clicks the "Find Key" button again. Space is focused for editing, no problem, but the "Press any key to edit..." label is shown instead of "Editing key: Space." This could cause potential confusion for the end-user. Similarly, hitting [Enter] doesn't focus Enter for editing, which is a bit frustrating but I'm not sure what I can do about that. Not looking to restructure/rewrite the unit or change the way that the app handles reading/writing key names, etc. I just want to know if there's a simple way to stop the Space bar from auto-clicking the "Find Key" button. Tried "if Key = VK_SPACE then Exit;" on the form's OnKeyDown event handler and on the [btnFindKey] OnKeyDown event handler and similar things like that, nothing seems to work. --- As an aside, if I can't find a way to get the dialog to always listen for key presses without first pressing "Find Key", then ideally it'd be better if FindKey must be pressed in order to focus any key for editing. At the moment, it's sometimes possible to press a few keys after hitting "Find Key" and each one will be focused, but then some won't be. I can't figure out what's causing this behaviour, but if there's a way to stop the form from listening for key presses once one has been focused in the list, that would also be something of an improvement.
-
I have a form with a treeview, which can be browsed using the arrow keys. Once an item in the treeview is selected, hitting an "OK" button on the form (which has the modal result mrOK) will close the form, and load the currently selected item into the app. What I want to do is assign VK_RETURN (which I believe is the [Enter] key...?) to the OK button, so that when browsing the treeview using keys, the user can just hit Enter/Return to load the currently selected item. btnOKClick has its own procedure, detailed here: procedure TFLevelSelect.btnOKClick(Sender: TObject); begin WriteToParams; ModalResult := mrOk; end; I can enter "WriteToParams;" into the Treeview's OnKeyDown procedure, but this doesn't actually have any effect until the OK button is pressed. So, one option is to tell the OnKeyDown procedure to also "virtually press the OK button" (which I'm not sure is even possible...?) - this would be my preferred method, if it can be done. Another option is to assign a hotkey to btnOKClick. The only problem with this is that there are multiple other buttons on the form, all of which already respond to [Enter] when Tab-selected. If I assign [Enter] as a hotkey to btnOKClick, then [Enter] either can't then be used for any of the other buttons on the form - or, worse, the app will crash because it won't know which button to press if the Tab is on a different button than 'OK', and the user hits [Enter]. Any and all suggestions/help welcome. I apologise if I haven't provided any necessary information.