Aggie85 Posted July 15, 2022 Share Posted July 15, 2022 Howdy! I would like the Clear button on edits to only show when the edit button has the focus. How do I achieve this? All the best, Aggie85 Quote Link to comment Share on other sites More sharing options...
Sherzod Posted July 15, 2022 Share Posted July 15, 2022 2 hours ago, Aggie85 said: I would like the Clear button on edits to only show when the edit button has the focus. How do I achieve this? Hello, One possible solution: procedure TMainForm.UniFormCreate(Sender: TObject); begin with UniEdit1 do if ClearButton then begin JSInterface.JSAddListener('focus', 'function(cmp){if (cmp.getValue()!="") cmp.getTrigger("clear").show()}'); JSInterface.JSAddListener('blur', 'function(cmp){cmp.getTrigger("clear").hide()}'); end; end; Quote Link to comment Share on other sites More sharing options...
Aggie85 Posted July 15, 2022 Author Share Posted July 15, 2022 Sherzod, Thanks as usual! All the best, Aggie85 Quote Link to comment Share on other sites More sharing options...
eduardosuruagy Posted July 15, 2022 Share Posted July 15, 2022 2 hours ago, Sherzod said: Hello, One possible solution: procedure TMainForm.UniFormCreate(Sender: TObject); begin with UniEdit1 do if ClearButton then begin JSInterface.JSAddListener('focus', 'function(cmp){if (cmp.getValue()!="") cmp.getTrigger("clear").show()}'); JSInterface.JSAddListener('blur', 'function(cmp){cmp.getTrigger("clear").hide()}'); end; end; Where do I put this code? I put it in onCreate but it didn't work Quote Link to comment Share on other sites More sharing options...
Sherzod Posted July 15, 2022 Share Posted July 15, 2022 3 minutes ago, eduardosuruagy said: I put it in onCreate but it didn't work ClearButton = True ? Quote Link to comment Share on other sites More sharing options...
Aggie85 Posted July 15, 2022 Author Share Posted July 15, 2022 Howdy Sherzod, Need to replace "clear" with 'clear' and it will work as expected. All the best, Aggie85 Quote Link to comment Share on other sites More sharing options...
Sherzod Posted July 16, 2022 Share Posted July 16, 2022 5 hours ago, Aggie85 said: Need to replace "clear" with 'clear' and it will work as expected. It's probably for C++Builder. Quote Link to comment Share on other sites More sharing options...
eduardosuruagy Posted July 16, 2022 Share Posted July 16, 2022 17 hours ago, Sherzod said: ClearButton = True ? Yes, When I open the form it looks like this, and after I focus on the edits it disappears with the X Quote Link to comment Share on other sites More sharing options...
Sherzod Posted July 16, 2022 Share Posted July 16, 2022 And without additional code? Which theme are you using? Quote Link to comment Share on other sites More sharing options...
eduardosuruagy Posted July 16, 2022 Share Posted July 16, 2022 52 minutes ago, Sherzod said: E sem código adicional? Qual tema você está usando? triton.modified Quote Link to comment Share on other sites More sharing options...
Sherzod Posted July 16, 2022 Share Posted July 16, 2022 1 hour ago, Sherzod said: And without additional code? ? Quote Link to comment Share on other sites More sharing options...
eduardosuruagy Posted July 16, 2022 Share Posted July 16, 2022 28 minutes ago, Sherzod said: ? Additional code where? Would it be in onCreate? Quote Link to comment Share on other sites More sharing options...
eduardosuruagy Posted July 16, 2022 Share Posted July 16, 2022 I made an example with just the edits UniGui Teste.rar Quote Link to comment Share on other sites More sharing options...
Sherzod Posted July 16, 2022 Share Posted July 16, 2022 1 hour ago, eduardosuruagy said: UniGui Teste.rar 56.64 kB · 1 download procedure TFormTeste.UniFormCreate(Sender: TObject); var I: Integer; begin for I := 0 to Self.ComponentCount - 1 do begin if Self.Components[I].ClassType = TUniEdit then begin with TUniEdit(Self.Components[I]) do begin if ClearButton then begin JSInterface.JSAddListener('afterrender', 'function(cmp){cmp.getTrigger("clear").hide()}'); //<-------- JSInterface.JSAddListener('focus', 'function(cmp){if (cmp.getValue()!="") cmp.getTrigger("clear").show()}'); JSInterface.JSAddListener('blur', 'function(cmp){cmp.getTrigger("clear").hide()}'); end; end; end; end; end; Quote Link to comment Share on other sites More sharing options...
eduardosuruagy Posted July 18, 2022 Share Posted July 18, 2022 On 7/16/2022 at 2:28 PM, Sherzod said: procedure TFormTeste.UniFormCreate(Sender: TObject); var I: Integer; begin for I := 0 to Self.ComponentCount - 1 do begin if Self.Components[I].ClassType = TUniEdit then begin with TUniEdit(Self.Components[I]) do begin if ClearButton then begin JSInterface.JSAddListener('afterrender', 'function(cmp){cmp.getTrigger("clear").hide()}'); //<-------- JSInterface.JSAddListener('focus', 'function(cmp){if (cmp.getValue()!="") cmp.getTrigger("clear").show()}'); JSInterface.JSAddListener('blur', 'function(cmp){cmp.getTrigger("clear").hide()}'); end; end; end; end; end; it worked thank you very much! 1 Quote Link to comment Share on other sites More sharing options...
fraxzi Posted November 22, 2022 Share Posted November 22, 2022 On 7/17/2022 at 1:28 AM, Sherzod said: procedure TFormTeste.UniFormCreate(Sender: TObject); var I: Integer; begin for I := 0 to Self.ComponentCount - 1 do begin if Self.Components[I].ClassType = TUniEdit then begin with TUniEdit(Self.Components[I]) do begin if ClearButton then begin JSInterface.JSAddListener('afterrender', 'function(cmp){cmp.getTrigger("clear").hide()}'); //<-------- JSInterface.JSAddListener('focus', 'function(cmp){if (cmp.getValue()!="") cmp.getTrigger("clear").show()}'); JSInterface.JSAddListener('blur', 'function(cmp){cmp.getTrigger("clear").hide()}'); end; end; end; end; end; Hi @Sherzod, Good day! I tried with TUniDBEdit, but the "afterrender" has no effect.. If I move the record from UniDBGrid, the display TUniDBEdit always show the clearbutton. Any workarround? Thanks Frances Quote Link to comment Share on other sites More sharing options...
Sherzod Posted November 22, 2022 Share Posted November 22, 2022 Hello @fraxzi I will check. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted November 22, 2022 Share Posted November 22, 2022 46 minutes ago, fraxzi said: I tried with TUniDBEdit, but the "afterrender" has no effect.. If I move the record from UniDBGrid, the display TUniDBEdit always show the clearbutton. Works for me. Maybe you forgot to set ClearButton to True? Quote Link to comment Share on other sites More sharing options...
fraxzi Posted November 23, 2022 Share Posted November 23, 2022 Hi @Sherzod, The ClearButton property is 'true'. I carefully follow the above. I am using uniGui 1.90.0.1564. Thanks, Frances Quote Link to comment Share on other sites More sharing options...
fraxzi Posted November 23, 2022 Share Posted November 23, 2022 here's the gif ... note: dataset AutoEdit is false. Thanks and regards, Frances Quote Link to comment Share on other sites More sharing options...
Sherzod Posted November 23, 2022 Share Posted November 23, 2022 19 hours ago, fraxzi said: If I move the record from UniDBGrid Sorry, I didn't pay attention to what you wrote. I will check. Quote Link to comment Share on other sites More sharing options...
fraxzi Posted November 29, 2022 Share Posted November 29, 2022 On 11/23/2022 at 12:12 PM, Sherzod said: Sorry, I didn't pay attention to what you wrote. I will check. Hi @Sherzod, Any update? Thanks, Frances Quote Link to comment Share on other sites More sharing options...
Sherzod Posted November 29, 2022 Share Posted November 29, 2022 Hi @fraxzi Sorry, I forgot, now I'm looking to find a solution. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted November 29, 2022 Share Posted November 29, 2022 13 minutes ago, fraxzi said: Any update? Try this approach, added dirtychange event: procedure TMainForm.UniFormCreate(Sender: TObject); var I: Integer; begin for I := 0 to Self.ComponentCount - 1 do begin if Self.Components[I].ClassType = TUniDBEdit then begin with TUniDBEdit(Self.Components[I]) do begin if ClearButton then begin JSInterface.JSAddListener('afterrender', 'function(cmp){cmp.getTrigger("clear").hide()}'); JSInterface.JSAddListener('focus', 'function(cmp){if (cmp.getValue()!="") cmp.getTrigger("clear").show()}'); JSInterface.JSAddListener('blur', 'function(cmp){cmp.getTrigger("clear").hide()}'); JSInterface.JSAddListener('dirtychange', 'function(cmp){cmp.getTrigger("clear").hide()}'); //<-------- end; end; end; end; end; Quote Link to comment Share on other sites More sharing options...
fraxzi Posted November 29, 2022 Share Posted November 29, 2022 2 hours ago, Sherzod said: Try this approach, added dirtychange event: procedure TMainForm.UniFormCreate(Sender: TObject); var I: Integer; begin for I := 0 to Self.ComponentCount - 1 do begin if Self.Components[I].ClassType = TUniDBEdit then begin with TUniDBEdit(Self.Components[I]) do begin if ClearButton then begin JSInterface.JSAddListener('afterrender', 'function(cmp){cmp.getTrigger("clear").hide()}'); JSInterface.JSAddListener('focus', 'function(cmp){if (cmp.getValue()!="") cmp.getTrigger("clear").show()}'); JSInterface.JSAddListener('blur', 'function(cmp){cmp.getTrigger("clear").hide()}'); JSInterface.JSAddListener('dirtychange', 'function(cmp){cmp.getTrigger("clear").hide()}'); //<-------- end; end; end; end; end; YES! You're the Man @Sherzod!! "dirtychange" works like a charm. Thanks much with your superb support. -Frances 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.