morphine Posted January 24, 2022 Share Posted January 24, 2022 Hi All, How would you enable / disable - UniPanel1.ToolButtons[0] to stop the user from clicking on the button? Thanks. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted January 24, 2022 Share Posted January 24, 2022 Hello, I think you can use the following approach. 1. CustomCSS: .customDisabledCls { pointer-events: none; } For example for the first button (UniPanel1). 2. "Disable": procedure TMainForm.UniButton1Click(Sender: TObject); begin with UniPanel1 do JSInterface.JSCall('addCls', ['customDisabledCls'], ToolButtons[0].JSMenuItem); end; 3. "Enable": procedure TMainForm.UniButton2Click(Sender: TObject); begin with UniPanel1 do JSInterface.JSCall('removeCls', ['customDisabledCls'], ToolButtons[0].JSMenuItem); end; 4. Important! You should also consider this logic, in the OnToolClick event: procedure TMainForm.UniPanel1ToolClick(Sender: TUniCustomButtonItem); begin // end; 1 Quote Link to comment Share on other sites More sharing options...
morphine Posted January 24, 2022 Author Share Posted January 24, 2022 Perfect, thank you. Last question, where can I change the disabled button's background color or opacity to make it "look" disabled? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted January 24, 2022 Share Posted January 24, 2022 9 minutes ago, morphine said: Last question, where can I change the disabled button's background color or opacity to make it "look" disabled? .customDisabledCls { pointer-events: none; opacity: 0.4; } Quote Link to comment Share on other sites More sharing options...
morphine Posted January 24, 2022 Author Share Posted January 24, 2022 Thank you Sherzod, appreciate it. 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.