Jump to content

Change caption Label.


picyka

Recommended Posts

procedure TMainForm.lbAtualizarDashBoardClick(Sender: TObject);
begin
  var lIconOld := Self.lbAtualizarDashBoard.Caption;
  try
    Self.lbAtualizarDashBoard.Caption := '<i class="fas fa-sync fa-spin"></i>';
    Self.LoadGraficos(Self.cbMesDadosGrafico.Text);
  finally
    Self.lbAtualizarDashBoard.Caption := lIconOld;
  end;
end;

Good morning, I hope everyone is well. How to click on a label, change its caption to an animation,

then go back to the original caption ?

 

Grateful.

Link to comment
Share on other sites

Dois minutos atrás, Sherzod disse:

Olá

Poderia explicar com mais detalhes?

I have a label, when I click on it, I want to trigger a process, changing its caption to an

animated font Self.lbUpdateDashBoard.Caption := '<i class="fas fas-sync fa-spin"></i>';

 

after finishing the process, go back to the original source

sis.png

Link to comment
Share on other sites

1 minuto atrás, Sherzod disse:

Você precisa fazer isso no evento Click ("no lado do cliente").

procedure TMainForm.lbAtualizarDashBoardClick(Sender: TObject);
begin
  var lIconOld := Self.lbAtualizarDashBoard.Caption;
  try
    Self.lbAtualizarDashBoard.Caption := '<i class="fas fa-sync fa-spin"></i>';
    Self.lbAtualizarDashBoard.JSInterface.JSCode('MainForm.lbAtualizarDashBoard.setHtml('''+Self.lbAtualizarDashBoard.Caption+''');');
    Self.LoadGraficos(Self.cbMesDadosGrafico.Text);
  finally
    Self.lbAtualizarDashBoard.Caption := lIconOld;
    Self.lbAtualizarDashBoard.JSInterface.JSCode('MainForm.lbAtualizarDashBoard.setHtml('''+Self.lbAtualizarDashBoard.Caption+''');');
  end;
end;

I tried something like this but it didn't work

Link to comment
Share on other sites

41 minutos atrás, Sherzod disse:

Você pode fazer a abordagem daqui:

 

{ TUniLabelHelper }

procedure TUniLabelHelper.ConfigureIcon(Icon: String);
begin
  Self.ClientEvents.UniEvents.Values['ajaxCallback'] := 'function ajaxCallback(sender, response) { try {sender.setDisabled(false)} catch(err){}; }';

  with Self.JSInterface do
  begin
    JSConfig('_text', [Self.Caption]);
    JSConfig('_iconCls', [Icon]);
    JSAddListener('disable', 'function(){this.setHtml(''<i class="fas fa-sync fa-spin"></i>'')}');
    JSAddListener('enable', 'function(){this.setHtml(this.getConfig("_iconCls")); this.setHtml(this.getConfig("_text"))}');
    JSAddListener('click', 'function(){this.setDisabled(true);}');
  end;
end;

Self.lbAtualizarDashBoard.ConfigureIcon('<i class="fas fa-chart-line"></i>');

My fault, I had forgotten about this routine

Link to comment
Share on other sites

1 hour ago, picyka said:

I tried something like this but it didn't work

procedure TMainForm.UniFormCreate(Sender: TObject);
begin
  with UniLabel1 do
  begin
    TextConversion := txtHTML;
    CustomAttribs.Values['originalCaption'] := Caption;
    JSInterface.JSAddListener('click', 'function(){this.setHtml("<i class=\"fas fa-sync fa-spin\"></i>"); this.setDisabled(true)}');
  end;
end;

procedure TMainForm.UniLabel1Click(Sender: TObject);
begin
  Sleep(5000);

  with (Sender as TUniLabel) do
  begin
    JSInterface.JSCall('setHtml', [CustomAttribs.Values['originalCaption']]);
    JSInterface.JSCall('setDisabled', [False]); //try finally
  end;

end;

 

Link to comment
Share on other sites

Dois minutos atrás, Sherzod disse:
procedure TMainForm.UniFormCreate(Sender: TObject);
begin
  with UniLabel1 do
  begin
    TextConversion := txtHTML;
    CustomAttribs.Values['originalCaption'] := Caption;
    JSInterface.JSAddListener('click', 'function(){this.setHtml("<i class=\"fas fa-sync fa-spin\"></i>"); this.setDisabled(true)}');
  end;
end;

procedure TMainForm.UniLabel1Click(Sender: TObject);
begin
  Sleep(5000);

  with (Sender as TUniLabel) do
  begin
    JSInterface.JSCall('setHtml', [CustomAttribs.Values['originalCaption']]);
    JSInterface.JSCall('setDisabled', [False]); //try finally
  end;

end;

 

Cool, we already have two usage options. Thank you master.

  • Like 1
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...