Jump to content

Howto Disable / Enable a UniSpeedbutton from Client-Side?


Kattes

Recommended Posts

Hi,

I tried following without any success:

procedure TuSeatingDesignerFrame.UniPanel2Click(Sender: TObject);
var
  s : string;
begin
//  s := ' document.getElementById("' + UniSpeedButtonUndo.JSName + '_id").disabled = true; ';
  s := '$(''#'+UniSpeedButtonUndo.JSId + ''').disabled=true';
  MessageDlg('JS: '+s, mtInformation, [mbOk], nil);
  UniSession.AddJS(s);
end;
 

Link to comment
Share on other sites

9 hours ago, Kattes said:

I tried following without any success:

procedure TuSeatingDesignerFrame.UniPanel2Click(Sender: TObject);
var
  s : string;
begin
//  s := ' document.getElementById("' + UniSpeedButtonUndo.JSName + '_id").disabled = true; ';
  s := '$(''#'+UniSpeedButtonUndo.JSId + ''').disabled=true';
  MessageDlg('JS: '+s, mtInformation, [mbOk], nil);
  UniSession.AddJS(s);
end;
 

Well, this code is not a client side code

Link to comment
Share on other sites

Thank you, this is working fine:

procedure TuSeatingDesignerFrame.UniPanel2Click(Sender: TObject);
var
  s : string;
begin
  s := UniSpeedButtonUndo.JSName + '.setDisabled(true)';
  UniSession.AddJS(s);
end;

..but finally does not really help me to solve my current problem, which I want to explain you a bit more in detail.

Picture below describes my current configuration.
I am using a MainForm, which uses the great UniTreeMenu component. Each tree-item click will dynamically create a TUniFrame, which finally allows my to struct my project,
because each TUniFrame uses its own Delphi unit. Current module I am working on is a seating manager, which is also running in his own frame. The graphically components I am using is FabricJS - a very cool JS graphic engine. All needed Fabric routines including my own JS interfaces are running in the UniHTMLFrame. As long as I simply want to control from the tool bar (e.g. deleting a selected object, by clicking the litter bin symbol)  routines defined in the HTMLframe this is easy and possible. But now I want to control the buttons from the tool bar from the HTMLframe side. In my case I want  to enable and disable the Undo and Redo buttons depending of the status of a JS variable I created in the HTMLframe. 

Is there any way to do that?

IMage.png.913e8bc6cde982ea77bb977927091533.png

Link to comment
Share on other sites

Ups, after playing a bit with my sample code, I was able to solve the problem by myself. :D

For the sample code the solution is:

MainForm.UniSpeedButtonRedo.setDisable(true);

..and for my special case using uniFrame it is: 

uSeatingDesignerFrame.UniSpeedButtonRedo.setDisable(true);

with uSeatingDesignerFrame as Name of the used TUniFrame.

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...