AdvMetroButton And Touch

When you add a AdvMetroButton to a Delphi XE4 Metro Application Form the OnMouseDown event does not execute with touch. The button responds to a finger touch but only after lifting the finger from the button. Then both the OnMouseDown and OnMouseUp events execute.



How do you get the AdvMetroButton to respond to OnMouseDown just like the mouse?



With the mouse, a left button mouse down executes OnMouseDown. When you release left mouse button the OnMouseUp event executes.



A finger touch and hold does not execute OnMouseDown until the finger is removed from the button and then both the OnMouseDown and OnMouseUp events execute.



I need the button to respond to a finger touch and hold so that it acts like a mouse to toggle an action. One action is assigned to OnMouseDown and another action is assigned to OnMouseUp.



Is this possible?

This is actually an issue of the touch driver that maps the finger touch to a mouse down / mouse up. You should see the same behavior with mouse events on other controls. As this is an issue at driver level, there is not really something we can do about this.

I am not sure if what you said is true. Many other components I use respond to OnMouseDown with touch and act correctly. Can you look into this a little bit?

I think I am correct. I just tested it:



This works:



procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;

Shift: TShiftState; X, Y: Integer);

begin

ImageEnView1.Assign(ImageEnViewOriginal1);

AppBar1.Visible := True;

AppBar1.BringToFront;

AppBar2.Visible := True;

AppBar2.BringToFront;

end;



procedure TForm1.Image1MouseUp(Sender: TObject; Button: TMouseButton;

Shift: TShiftState; X, Y: Integer);

begin

ImageEnView1.Assign(ImageEnViewEdited1);

AppBar1.Visible := True;

AppBar1.BringToFront;

AppBar2.Visible := True;

AppBar2.BringToFront;

end;



This does not work: - the AdvMetroButtonMouseDown does not execute with touch and hold, but Image1MouseDown does execute.



procedure TForm1.AdvMetroButton1MouseDown(Sender: TObject; Button: TMouseButton;

Shift: TShiftState; X, Y: Integer);

begin

ImageEnView1.Assign(ImageEnViewOriginal1);

AppBar1.Visible := True;

AppBar1.BringToFront;

AppBar2.Visible := True;

AppBar2.BringToFront;

end;



procedure TForm1.AdvMetroButton1MouseUp(Sender: TObject; Button: TMouseButton;

Shift: TShiftState; X, Y: Integer);

begin

ImageEnView1.Assign(ImageEnViewEdited1);

AppBar1.Visible := True;

AppBar1.BringToFront;

AppBar2.Visible := True;

AppBar2.BringToFront;

end;

I was able to get a response with touch this way:



procedure TForm1.AdvMetroButton1MouseDown(Sender: TObject; Button: TMouseButton;

Shift: TShiftState; X, Y: Integer);

begin

if AdvMetroButton1.Down then

begin

    ImageEnView1.Assign(ImageEnViewOriginal1);

    AppBar1.Visible := True;

    AppBar1.BringToFront;

    AppBar2.Visible := True;

    AppBar2.BringToFront;

end

else

begin

    ImageEnView1.Assign(ImageEnViewEdited1);

    AppBar1.Visible := True;

    AppBar1.BringToFront;

    AppBar2.Visible := True;

    AppBar2.BringToFront;

end;

end;