Hi.
So, just switched to RAD XE3 to use Metropolis UI feature, and therefore started to completely rearrange and redesign my app to make it a little nicer, only this time I've chosen FireMonkey Metropolis App, since it has some good components, such as TSwitch (slide switch).
Everything seems to work fine (with modifications and spending lot of time...), but can't find a way to call Switch procedure via VK buttons.
The VK procedure is able to show toolbar, and to show message with ShowMessage('Hello'); as well, but I can't call switch procedure.

The TSwitch has the OnSwitch event (It's a replacement for an OnChange event), so the call is:

procedure THome.Switch1Switch(Sender: TObject);
begin
  if Switch1.IsChecked=True then
  LabelStatus:=On
  else LabelStatus:=Off;
end;

The VK procedure is placed on form's OnKeyDown event:

procedure THome.FormKeyDown(Sender: TObject; var Key: Word;
  var KeyChar: Char; Shift: TShiftState);
begin
//  if Key = VKNumpad1 then
    if KeyChar = '1' then
    Self.Switch1Switch(Sender);

I have tried several options to call it, but seems like the VK works fine (ShowMessage is shown, if present).
Any ideas why this doesn't work and how would it work? Since I successfuly call the FormCreate procedure with

Self.FormCreate(Sender);

...

Thanks. :)

And Merry Christmas! :)

So far found a way around:

  if KeyChar = '1' then
    begin
      if   Switch1.IsChecked=True
      then Switch1.IsChecked:=False
      else Switch1.IsChecked:=True;
    end;

Though I'm sure that's not the correct way, seems to work, since that calls the OnSwitch procedure up so... For now that's gonna be fine. Still looking forward for any useful answer. :)

Cheers

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.