View Issue Details

IDProjectCategoryView StatusLast Update
0026071LazarusLCLpublic2014-04-26 19:27
ReporterJoachim PaepkeAssigned ToBart Broersma 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Platformi386OSLinuxOS Version3.2.0-4-686-pae
Product Version1.3 (SVN)Product Build44803 
Target VersionFixed in Version1.4 
Summary0026071: TEditButton.ButtonOnlyWhenFocused
DescriptionAttached example has a form with a TEditButton on it. Nothing else.
ButtonOnlyWhenFocused is set to true via ObjectInspector
On runtime the EditButton is focused, but the button is not visible.
In this example it is not possible to get the button visible.
Only if there would be something else on the form, so You can change the focus, then by returning to the EditButton the button will be visible
TagsNo tags attached.
Fixed in Revisionr44811
LazTarget-
WidgetsetGTK 2
Attached Files
  • example.zip (126,943 bytes)
  • result.txt (640 bytes)
    TCustomEditButton.CalcButtonVisible:
     Visible = TRUE
     FEdit.Focused = FALSE
     inherited Focused = FALSE
     FButtonOnlyWhenFocused = TRUE
     (FEdit.Focused or not FButtonOnlyWhenFocused) = FALSE
     Result = FALSE
    TCustomEditButton.Loaded
    TCustomEditButton.CalcButtonVisible:
     Visible = TRUE
     FEdit.Focused = FALSE
     inherited Focused = FALSE
     FButtonOnlyWhenFocused = TRUE
     (FEdit.Focused or not FButtonOnlyWhenFocused) = FALSE
     Result = FALSE
    TCustomEditButton.CalcButtonVisible:
     Visible = TRUE
     FEdit.Focused = FALSE
     inherited Focused = FALSE
     FButtonOnlyWhenFocused = TRUE
     (FEdit.Focused or not FButtonOnlyWhenFocused) = FALSE
     Result = FALSE
    
    result.txt (640 bytes)
  • resultwithtabstoptrue.txt (637 bytes)
    TCustomEditButton.CalcButtonVisible:
     Visible = TRUE
     FEdit.Focused = FALSE
     inherited Focused = FALSE
     FButtonOnlyWhenFocused = TRUE
     (FEdit.Focused or not FButtonOnlyWhenFocused) = FALSE
     Result = FALSE
    TCustomEditButton.Loaded
    TCustomEditButton.CalcButtonVisible:
     Visible = TRUE
     FEdit.Focused = FALSE
     inherited Focused = FALSE
     FButtonOnlyWhenFocused = TRUE
     (FEdit.Focused or not FButtonOnlyWhenFocused) = FALSE
     Result = FALSE
    TCustomEditButton.CalcButtonVisible:
     Visible = TRUE
     FEdit.Focused = TRUE
     inherited Focused = FALSE
     FButtonOnlyWhenFocused = TRUE
     (FEdit.Focused or not FButtonOnlyWhenFocused) = TRUE
     Result = TRUE
    

Activities

Joachim Paepke

2014-04-24 21:53

reporter  

example.zip (126,943 bytes)

Bart Broersma

2014-04-25 21:41

developer   ~0074584

When i run your roject it shows the button as expected.
However I am on Windows (win32 widgetset) and you're on linux/GTK2.

Could you test for me:

procedure TCustomEditButton.Loaded;
begin
  writeln('TCustomEditButton.Loaded');
  inherited Loaded;
  {
    inherited Loaded sends a CM_PARENTFONTCHANGED message, which then
    also sets FEdit's color, which is undesired.
  }
  if GetColor <> FInitialColor then SetColor(FInitialColor);
  CheckButtonVisible;
end;


function TCustomEditButton.CalcButtonVisible: Boolean;
begin
  writeln('TCustomEditButton.CalcButtonVisible:');
  writeln(' Visible = ',Visible);
  writeln(' FEdit.Focused = ',FEdit.Focused);
  writeln(' inherited Focused = ',inherited Focused);
  writeln(' FButtonOnlyWhenFocused = ',FButtonOnlyWhenFocused);
  writeln(' (FEdit.Focused or not FButtonOnlyWhenFocused) = ',(FEdit.Focused or not FButtonOnlyWhenFocused));
  Result := (csdesigning in ComponentState) or
            (Visible and (FEdit.Focused or not FButtonOnlyWhenFocused));
  writeln(' Result = ',Result);
end;

Then reuild the app and run from commandline.

On Win32 the outut is:

C:\Users\Bart\LazarusProjecten\bugs\ButtonEdit\focus>tes
TCustomEditButton.CalcButtonVisible: //this is while loading the component
  Visible = TRUE
  FEdit.Focused = FALSE
  inherited Focused = FALSE
  FButtonOnlyWhenFocused = TRUE
  (FEdit.Focused or not FButtonOnlyWhenFocused) = FALSE
  Result = FALSE
TCustomEditButton.Loaded
TCustomEditButton.CalcButtonVisible: //this is after loading
  Visible = TRUE
  FEdit.Focused = FALSE
  inherited Focused = FALSE
  FButtonOnlyWhenFocused = TRUE
  (FEdit.Focused or not FButtonOnlyWhenFocused) = FALSE
  Result = FALSE
TCustomEditButton.CalcButtonVisible:
  Visible = TRUE
  FEdit.Focused = TRUE
  inherited Focused = FALSE //this is the focus of the container
  FButtonOnlyWhenFocused = TRUE
  (FEdit.Focused or not FButtonOnlyWhenFocused) = TRUE
  Result = TRUE

Thanks in advance.

Joachim Paepke

2014-04-25 23:39

reporter  

result.txt (640 bytes)
TCustomEditButton.CalcButtonVisible:
 Visible = TRUE
 FEdit.Focused = FALSE
 inherited Focused = FALSE
 FButtonOnlyWhenFocused = TRUE
 (FEdit.Focused or not FButtonOnlyWhenFocused) = FALSE
 Result = FALSE
TCustomEditButton.Loaded
TCustomEditButton.CalcButtonVisible:
 Visible = TRUE
 FEdit.Focused = FALSE
 inherited Focused = FALSE
 FButtonOnlyWhenFocused = TRUE
 (FEdit.Focused or not FButtonOnlyWhenFocused) = FALSE
 Result = FALSE
TCustomEditButton.CalcButtonVisible:
 Visible = TRUE
 FEdit.Focused = FALSE
 inherited Focused = FALSE
 FButtonOnlyWhenFocused = TRUE
 (FEdit.Focused or not FButtonOnlyWhenFocused) = FALSE
 Result = FALSE
result.txt (640 bytes)

Joachim Paepke

2014-04-25 23:41

reporter   ~0074585

Done; see "result.txt"
Any focused state is always false!
At the moment I have no idea about it, but I will try a little bit around

Joachim Paepke

2014-04-26 00:14

reporter  

resultwithtabstoptrue.txt (637 bytes)
TCustomEditButton.CalcButtonVisible:
 Visible = TRUE
 FEdit.Focused = FALSE
 inherited Focused = FALSE
 FButtonOnlyWhenFocused = TRUE
 (FEdit.Focused or not FButtonOnlyWhenFocused) = FALSE
 Result = FALSE
TCustomEditButton.Loaded
TCustomEditButton.CalcButtonVisible:
 Visible = TRUE
 FEdit.Focused = FALSE
 inherited Focused = FALSE
 FButtonOnlyWhenFocused = TRUE
 (FEdit.Focused or not FButtonOnlyWhenFocused) = FALSE
 Result = FALSE
TCustomEditButton.CalcButtonVisible:
 Visible = TRUE
 FEdit.Focused = TRUE
 inherited Focused = FALSE
 FButtonOnlyWhenFocused = TRUE
 (FEdit.Focused or not FButtonOnlyWhenFocused) = TRUE
 Result = TRUE

Joachim Paepke

2014-04-26 00:16

reporter   ~0074586

I tried the following and now the button is visible as expected:
I simply set TabStop=true in the object inspector
Now see "resultwithtabstoptrue.txt" is same as Yours

Joachim Paepke

2014-04-26 01:37

reporter   ~0074587

Last edited: 2014-04-26 01:37

View 2 revisions

Anyway; TEdit from StdCtrls has TabStop=true as default
Shouldnt TEditButton have this not also?
Perhaps this would be the easiest solution

Zeljan Rikalo

2014-04-26 10:02

developer   ~0074589

This smells like another gtk2 focus bug.

Bart Broersma

2014-04-26 11:58

developer   ~0074591

Well, at least this is not a regression then. The code to calculate visibilty of the button in essence has not changed.
Unassigning since this seems to be a GTK WS issue that maybe others have more knowledge of.

Juha Manninen

2014-04-26 12:14

developer   ~0074592

> Anyway; TEdit from StdCtrls has TabStop=true as default. Shouldnt TEditButton have this not also?

IMO yes absolutely. In this regard TEditButton is similar with TEdit.

Bart Broersma

2014-04-26 12:18

developer   ~0074593

I made TabStop True by default in r44807 and this now also sets the FEdit TabStop (which was always true).

Joachim Paepke

2014-04-26 13:03

reporter   ~0074594

Just tested. Is working as expected: Button is visible and tabbing works.
Feel free to close

Zeljan Rikalo

2014-04-26 14:03

developer   ~0074596

One small thing is missing: container (TCustomControl) of TEdit is missing ControlStyle + [csNoFocus], so container cannot grab focus in any case.

Bart Broersma

2014-04-26 14:40

developer   ~0074598

Last edited: 2014-04-26 15:11

View 2 revisions

For me it also works when TabStop = False under Linx/GTK2 (Lazarus r44807, gtk2-2.24.19-1.fc18.i686, Fedora Core 18 running a VirtualBox with Win7 as host).

@Zeljan: ControlStyle + [csNoFocus], this will prevent the container from getting focus? That would indeed be nice. Currently I have overridden SetFocus and DoEnter to redirect focus to FEdit instead.
Will this cause any issues when doing "Form1.ActiveControl := EditButton1;" ?

Bart Broersma

2014-04-26 15:19

developer   ~0074602

Well, to answer my own questions.
I still need the redirection in DoEnter (after applying csNofocus), otherwise you cannot Tab into (or out of) the control anymore...
Aplied in r44811.

@Joachim: please test with r44811 and with TabStop = False.

Joachim Paepke

2014-04-26 16:14

reporter   ~0074605

Played around a little bit with different settings and as I see the behaviour is exactly the same as a normal TEdit and the visible-state of the button is also always (TabStop=true and TabStop=false) as expected

Bart Broersma

2014-04-26 17:15

developer   ~0074611

Please close if OK.

Joachim Paepke

2014-04-26 19:26

reporter   ~0074612

Feeling good with this ;-)
Closing . . .

Issue History

Date Modified Username Field Change
2014-04-24 21:53 Joachim Paepke New Issue
2014-04-24 21:53 Joachim Paepke File Added: example.zip
2014-04-25 07:20 Zeljan Rikalo Assigned To => Bart Broersma
2014-04-25 07:20 Zeljan Rikalo Status new => assigned
2014-04-25 21:41 Bart Broersma LazTarget => -
2014-04-25 21:41 Bart Broersma Note Added: 0074584
2014-04-25 21:41 Bart Broersma Status assigned => feedback
2014-04-25 23:39 Joachim Paepke File Added: result.txt
2014-04-25 23:41 Joachim Paepke Note Added: 0074585
2014-04-25 23:41 Joachim Paepke Status feedback => assigned
2014-04-26 00:14 Joachim Paepke File Added: resultwithtabstoptrue.txt
2014-04-26 00:16 Joachim Paepke Note Added: 0074586
2014-04-26 01:37 Joachim Paepke Note Added: 0074587
2014-04-26 01:37 Joachim Paepke Note Edited: 0074587 View Revisions
2014-04-26 10:02 Zeljan Rikalo Note Added: 0074589
2014-04-26 11:58 Bart Broersma Note Added: 0074591
2014-04-26 11:58 Bart Broersma Assigned To Bart Broersma =>
2014-04-26 11:58 Bart Broersma Status assigned => acknowledged
2014-04-26 12:14 Juha Manninen Note Added: 0074592
2014-04-26 12:18 Bart Broersma Note Added: 0074593
2014-04-26 13:03 Joachim Paepke Note Added: 0074594
2014-04-26 14:03 Zeljan Rikalo Note Added: 0074596
2014-04-26 14:40 Bart Broersma Note Added: 0074598
2014-04-26 15:11 Bart Broersma Note Edited: 0074598 View Revisions
2014-04-26 15:19 Bart Broersma Note Added: 0074602
2014-04-26 15:20 Bart Broersma Status acknowledged => feedback
2014-04-26 16:14 Joachim Paepke Note Added: 0074605
2014-04-26 16:14 Joachim Paepke Status feedback => new
2014-04-26 17:15 Bart Broersma Fixed in Revision => r44811
2014-04-26 17:15 Bart Broersma Note Added: 0074611
2014-04-26 17:15 Bart Broersma Status new => resolved
2014-04-26 17:15 Bart Broersma Fixed in Version => 1.4
2014-04-26 17:15 Bart Broersma Resolution open => fixed
2014-04-26 17:15 Bart Broersma Assigned To => Bart Broersma
2014-04-26 19:26 Joachim Paepke Note Added: 0074612
2014-04-26 19:27 Joachim Paepke Status resolved => closed