Recent

Author Topic: TRadiogroups - Arrowkeys  (Read 1957 times)

Niklas

  • Newbie
  • Posts: 2
TRadiogroups - Arrowkeys
« on: October 23, 2017, 03:56:28 pm »
Hey,

is there a chance to block the keyevents on a TRadiogroup?

My goal is it, that a press on one of the arrowkeys doesn't increases or decreases the ItemIndex of my TRadiogroup,
because I need the Keyevent for another action.

Niklas
« Last Edit: January 08, 2018, 01:36:52 pm by Niklas »

rvk

  • Hero Member
  • *****
  • Posts: 6112
Re: TRadiogroups - Arrowkeys
« Reply #1 on: October 23, 2017, 04:09:24 pm »
Set the KeyPreview of the form to true and do this in FormKeyDown().
It will eat all Key up and down for a TRadioButton.

Code: Pascal  [Select][+][-]
  1. uses LCLType;
  2.  
  3. procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
  4. begin
  5.   if ActiveControl is TRadioButton then
  6.   begin
  7.     if Key in [VK_UP, VK_DOWN] then Key := 0;
  8.   end;
  9. end;

You can also do the other actions in that place.

Niklas

  • Newbie
  • Posts: 2
Re: TRadiogroups - Arrowkeys
« Reply #2 on: October 23, 2017, 04:18:21 pm »
Well, that was easy.
Thank you for your fast help!  8)

Niklas

 

TinyPortal © 2005-2018