alank2 5 Posted January 13, 2022 (edited) I created a TSpeedButton and set the StaysPressed property to true. I then was using IsPressed to see if it is pressed or not in the OnClick event. If I click it slowly it works, but if I click it quickly, the 2nd time the event is fired (and it does fire), the IsPressed property is not changed, but is the previous state. void __fastcall TTest::UpdateSearch() { //debug does it fire when clicked fast static int i1; i1++; Label1->Text=i1; if (Search[0]==0) { if (SBSpecialOnly->IsPressed) LSearch->Text="Type to search special"; else LSearch->Text="Type to search"; LSearch->FontColor=claDarkgray; } else { LSearch->FontColor=claBlack; LSearch->Text=Search; } } Edited January 13, 2022 by alank2 Share this post Link to post
Rapunzel 1 Posted January 14, 2022 Hello, you are right, I can reproduce the issue. I used a listbox to record the IsPressed status in three events. If you click quickly, you can see that the status in OnClick has not changed yet. You can use the OnMouseUp event instead. procedure TForm4.btnSpecialOnlyMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Single); begin if btnSpecialOnly.IsPressed then begin LB.Items.Add('MouseDown TRUE'); end else begin LB.Items.Add('MouseDown FALSE'); end; end; procedure TForm4.btnSpecialOnlyClick(Sender: TObject); begin Label1.Text:=FCount.ToString; Inc(FCount); if btnSpecialOnly.IsPressed then begin LB.Items.Add('Click TRUE'); end else begin LB.Items.Add('Click FALSE'); end; end; procedure TForm4.btnSpecialOnlyMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Single); begin if btnSpecialOnly.IsPressed then begin LB.Items.Add('MouseUp TRUE'); end else begin LB.Items.Add('MouseUp FALSE'); end; end; Share this post Link to post
alank2 5 Posted January 14, 2022 It seems to be an immediate type thing. If I have code that looks at IsPressed later on, it seems to be correct, but not always in the OnClick that is changing it. Share this post Link to post
alank2 5 Posted January 18, 2022 Are there any workarounds on this issue? Share this post Link to post