* * *

Author Topic: LAMW UI questions  (Read 801 times)

CC

  • Jr. Member
  • **
  • Posts: 75
LAMW UI questions
« 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.
« Last Edit: September 25, 2017, 08:44:10 pm by CC »

RAW

  • Hero Member
  • *****
  • Posts: 577
Re: UI questions
« Reply #1 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;
Windows 7 Pro (x64 Sp1) And Windows XP Pro (x86 Sp3) - LAZARUS 1.8 FPC 3.0.4 // 1.7 FPC 3.1.1

Thaddy

  • Hero Member
  • *****
  • Posts: 4774
Re: UI questions
« Reply #2 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.
"Logically, no number of positive outcomes at the level of experimental testing can confirm a scientific theory, but a single counterexample is logically decisive."

CC

  • Jr. Member
  • **
  • Posts: 75
Re: UI questions
« Reply #3 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.
« Last Edit: September 25, 2017, 06:58:48 pm by CC »

jmpessoa

  • Hero Member
  • *****
  • Posts: 1012
Re: UI questions
« Reply #4 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!
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

jmpessoa

  • Hero Member
  • *****
  • Posts: 1012
Re: LAMW UI questions
« Reply #5 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....

Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

CC

  • Jr. Member
  • **
  • Posts: 75
Re: LAMW UI questions
« Reply #6 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. :)

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus