Lazarus

Programming => Operating Systems => Android => Topic started by: CC on September 25, 2017, 04:02:51 pm

Title: LAMW UI questions
Post by: CC on September 25, 2017, 04:02:51 pm
Hi,

1. I need to change its  color when a button is clicked to mimic grouped button behaviour  (always only one is selected). Trying to change the color  within the eventhandler crashes  the app.  Is there a way to do  this properly?

2. Z Order has no effect. Is there a way to insure that a  control appears on  top of an other when overlapped.
Title: Re: UI questions
Post by: RAW on September 25, 2017, 05:11:14 pm
1) How does the unproperly way look like?
    OS ? LAZ version ?

2) What's wrong with
Code: Pascal  [Select][+][-]
  1. Control.BringToFront;
Title: Re: UI questions
Post by: Thaddy on September 25, 2017, 06:52:50 pm
Note you may not be able to change the color on every widgetset for TButton: e.g. on windows that is not possible.
Title: Re: UI questions
Post by: CC on September 25, 2017, 06:53:53 pm
I forgot to mention a very important piece of information : I am using LAMW.  :-[

Quote
How does the unproperly way look like?

Trying to change the color  within the on click event handler crashes  the app.  The process of handling a click involves some UI updates after the event handler code is executed. So I assumed  that changing a  property value it uses  caused the crash.  Maybe my code needs to be wrapped between some kind of  "Begin update" and  "End update"  calls.
Title: Re: UI questions
Post by: jmpessoa on September 25, 2017, 08:21:43 pm

Quote
I forgot to mention a very important piece of information : I am using LAMW. 

Please, add "LAMW:" in your subject ...

Ok. I will try some solution!

Thank you!
Title: Re: LAMW UI questions
Post by: jmpessoa on September 27, 2017, 01:50:39 am
Hi, CC

This work:

Code: Pascal  [Select][+][-]
  1. procedure TAndroidModule1.jButton1Click(Sender: TObject);
  2. begin
  3.   jButton1.Enabled:= False;
  4. end;
  5.  
  6. procedure TAndroidModule1.jButton2Click(Sender: TObject);
  7. begin
  8.   jButton1.Enabled:= True;
  9. end;
  10.  

and this, too:

Code: Pascal  [Select][+][-]
  1. procedure TAndroidModule1.jButton1AfterDispatchDraw(Sender: TObject; canvas: JObject; tag: integer);
  2. begin
  3.   if jButton1.Enabled = False then
  4.      jButton1.BackgroundColor:= colbrYellow
  5.   else
  6.     jButton1.BackgroundColor:= colbrRed;
  7. end;
  8.  

NOTE:
Fixed jButton Enable property in design time....

Title: Re: LAMW UI questions
Post by: CC on October 22, 2017, 02:06:23 pm
jmpessoa,

I have just realized, that for some reason my "Thank you" comment  did not make into the topic earlier. So once again:

Thank you for creating LAMW and for your quick response.

Your solution works. There is small time-lag though, so I ended up putting every button into its own panel and coloring the parent instead. There is no delay this way. :)
TinyPortal © 2005-2018