Lazarus

Programming => Widgetset => GTK => Topic started by: andyH on May 30, 2019, 02:42:50 pm

Title: Show focus on tbutton
Post by: andyH on May 30, 2019, 02:42:50 pm
On a standard message dialog, focus is shown as in the attached. In this case a green border around the button, set I assume by the desktop theme.

How can I do this for my tbuttons? I've achieved something similar using onenter and onexit events to toggle the tbutton font bold, but can't find any tbutton property that affects the tbutton border.

Using lazarus 2.0.2 running under linux mint 19.0 cinnamon if relevant.
Title: Re: Show focus on tbutton
Post by: Zoran on May 30, 2019, 03:55:39 pm
What do you mean by "your" tbuttons?
If you use LCL's TButton, it is painted by desktop theme, so it should get the same appearance by default.

In my system (Mint 19, Xfce), there is no green border, but a "focus rectangle" inside button. It is quite same in MessageDialog and buttons I put on form.
See attached snapshots.
Title: Re: Show focus on tbutton
Post by: dsiders on May 30, 2019, 04:12:33 pm
What do you mean by "your" tbuttons?
If you use LCL's TButton, it is painted by desktop theme, so it should get the same appearance by default.

In my system (Mint 19, Xfce), there is no green border, but a "focus rectangle" inside button. It is quite same in MessageDialog and buttons I put on form.
See attached snapshots.

There are plenty of wonky themes floating around on the internet. Like, anything based on Murrine, as an example.
Title: Re: Show focus on tbutton
Post by: andyH on May 30, 2019, 04:30:54 pm
Thanks for the rapid responses. Using a bog standard theme - mint-x for controls, mint-y for everything else. By "my tbuttons" I mean buttons I have created on a form. See below. The only way I can see which button has focus is the code I've added for onenter and onexit. The OK button has focus in the screenshot - no green border which you would get with the theme (or the border on the text with the theme you are using in Xfce).

I have created the buttons (and form) manually, not by dropping objects onto the form designer. Code in the form constructor for the ok button is:
Code: Pascal  [Select][+][-]
  1.   OkBtn:= TButton.Create(Self);
  2.   with OkBtn do
  3.        begin
  4.          TabStop:= true;
  5.          OnEnter:= @HasFocus;
  6.          OnExit:= @LostFocus;
  7.          Default:= true;
  8.          Parent:= self;
  9.          Width:= 80;
  10.          Left:= 290;
  11.          Top:= 170;
  12.          Height:= 30;
  13.          Show;
  14.          Caption:= 'OK';
  15.          Enabled:= true;
  16.          OnClick := @OkBtnCK;
  17.          Visible:= true;
  18.        end;
I want the same effect you've got in xfce, i.e. a visual indication of which button has focus and consistent across all buttons in my app = same as a message dialog  :(
Title: Re: Show focus on tbutton
Post by: Zoran on May 30, 2019, 06:57:15 pm

I have created the buttons (and form) manually, not by dropping objects onto the form designer.

I doubt that it matters. Just to be sure, please try with putting the buttons in designer, do they behave differently?
Also, try with TBitBtn (pallete page Additional), as I think that message dialog actually use these. Is it same?
Title: Re: Show focus on tbutton
Post by: andyH on May 31, 2019, 12:25:18 am
Simple test - new project, put a couple of buttons on the form via the form designer - no change from my previous, no indication of focus on the buttons. Strange given the message dialogs and open/save dialogs behave as I want them to.

I've got a copy of lubuntu on this test laptop and, if I've time tomorrow, I'll stick lazarus on it and see what happens. Also have a play with TBitBn. Also see if anything changes with any of the other stock cinnamon themes. If I can't get a result on this, I'll have to disable tabbing and rely on the cancel and default properties for keyboard input on Tbuttons.

EDIT - it's a function of the controls setting in the theme, my default mint-x doesn't work (or any colour variant of mint-x). Changing to either adwaita or mint-y for the controls works - focus is shown on the tbutton. Not that you would expect it to, but played around with the desktop (linux mint/cinnamon/mint-y dark) and default icons - no change.

Sort of solved in the sense that the target for my app will be a lightweight distro booting off a usb stick - it won't be mint, so this problem should go away. Would still like to know why so I'll still have a play with TbitBn.
TinyPortal © 2005-2018