How can I simulate the press of a button?

前端 未结 5 708
天命终不由人
天命终不由人 2021-01-18 15:25

I want to test some forms. Is there a way to simulate the press of an Ok (or Cancel) button so that the button is pressed and fires the event handlers that are associated wi

5条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-18 16:25

    A correction for TSpeedButton:

    The behavior described by @David Heffernan does not quite hold true for speedbuttons in a group. Calling the Click method does not seem to affect the "Down" status of the buttons.

    To solve this I used the following code:

    MyButton.Click;
    MyButton.Down := True;
    

提交回复
热议问题