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. 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 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? 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; } 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 Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now