mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2026-02-19 19:56:56 +01:00
gtk intf: omitting TComboBoxBox LM_CHANGED events during popup
git-svn-id: trunk@10767 -
This commit is contained in:
parent
91e8c58c50
commit
5969cf4b03
2
.gitattributes
vendored
2
.gitattributes
vendored
@ -2766,6 +2766,8 @@ lcl/tests/test2_2labelattributes.lpi svneol=native#text/plain
|
||||
lcl/tests/test2_2labelattributes.lpr svneol=native#text/pascal
|
||||
lcl/tests/test2_3twosimpleforms1.lpi svneol=native#text/plain
|
||||
lcl/tests/test2_3twosimpleforms1.lpr svneol=native#text/plain
|
||||
lcl/tests/test3_1comboboxselect.lpi svneol=native#text/plain
|
||||
lcl/tests/test3_1comboboxselect.lpr svneol=native#text/plain
|
||||
lcl/tests/test3_2listboxdrawitem.lpi svneol=native#text/plain
|
||||
lcl/tests/test3_2listboxdrawitem.lpr svneol=native#text/plain
|
||||
lcl/tests/test4_1synedit.lpi svneol=native#text/plain
|
||||
|
||||
@ -103,10 +103,10 @@ end;
|
||||
|
||||
procedure TCustomComboBox.DoEnter;
|
||||
begin
|
||||
inherited DoEnter;
|
||||
//AutoSelect when DoEnter is fired by keyboard
|
||||
if (Style = csDropDownList) then Exit;//Non editable style
|
||||
if (FAutoSelect and not (csLButtonDown in ControlState)) then
|
||||
inherited DoEnter;
|
||||
//AutoSelect when DoEnter is fired by keyboard
|
||||
if (Style = csDropDownList) then Exit;//Non editable style
|
||||
if (FAutoSelect and not (csLButtonDown in ControlState)) then
|
||||
begin
|
||||
SelectAll;
|
||||
if (SelText = Text) then FAutoSelected := True;
|
||||
@ -115,8 +115,8 @@ end;
|
||||
|
||||
procedure TCustomComboBox.DoExit;
|
||||
begin
|
||||
FAutoSelected := False;
|
||||
inherited DoExit;
|
||||
FAutoSelected := False;
|
||||
inherited DoExit;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
|
||||
@ -351,16 +351,30 @@ end;
|
||||
function gtkchangedCB( widget: PGtkWidget; data: gPointer) : GBoolean; cdecl;
|
||||
var
|
||||
Mess : TLMessage;
|
||||
AComboBox: TComboBox;
|
||||
GtkComboWidget: PGtkCombo;
|
||||
begin
|
||||
Result := CallBackDefaultReturn;
|
||||
|
||||
if ComponentIsDestroyingHandle(TWinControl(Data))
|
||||
or (LockOnChange(PgtkObject(Widget),0)>0) then exit;
|
||||
|
||||
if (TObject(Data) is TComboBox) then begin
|
||||
AComboBox:=TComboBox(Data);
|
||||
GtkComboWidget:=PGtkCombo(AComboBox.Handle);
|
||||
if (GtkComboWidget^.popwin<>nil)
|
||||
and (GTK_WIDGET_VISIBLE(GtkComboWidget^.popwin)) then begin
|
||||
// Ignoring changed events during popup
|
||||
//DebugLn(['gtkchangedCB Ignoring changed events during popup']);
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
|
||||
{$IFDEF EventTrace}
|
||||
EventTrace('changed', data);
|
||||
{$ENDIF}
|
||||
Mess.Msg := LM_CHANGED;
|
||||
DeliverMessage(Data, Mess);
|
||||
|
||||
Result := CallBackDefaultReturn;
|
||||
end;
|
||||
|
||||
function gtkchanged_editbox( widget: PGtkWidget; data: gPointer) : GBoolean; cdecl;
|
||||
|
||||
56
lcl/tests/test3_1comboboxselect.lpi
Normal file
56
lcl/tests/test3_1comboboxselect.lpi
Normal file
@ -0,0 +1,56 @@
|
||||
<?xml version="1.0"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<PathDelim Value="/"/>
|
||||
<Version Value="5"/>
|
||||
<General>
|
||||
<Flags>
|
||||
<SaveClosedFiles Value="False"/>
|
||||
<SaveOnlyProjectUnits Value="True"/>
|
||||
</Flags>
|
||||
<SessionStorage Value="InProjectDir"/>
|
||||
<MainUnit Value="0"/>
|
||||
<IconPath Value="./"/>
|
||||
<TargetFileExt Value=""/>
|
||||
<Title Value="test1_1simpleform1"/>
|
||||
</General>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
|
||||
<ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
|
||||
</PublishOptions>
|
||||
<RunParams>
|
||||
<local>
|
||||
<FormatVersion Value="1"/>
|
||||
<LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
|
||||
</local>
|
||||
</RunParams>
|
||||
<RequiredPackages Count="1">
|
||||
<Item1>
|
||||
<PackageName Value="LCL"/>
|
||||
</Item1>
|
||||
</RequiredPackages>
|
||||
<Units Count="1">
|
||||
<Unit0>
|
||||
<Filename Value="test3_1comboboxselect.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="Test3_1comboboxselect"/>
|
||||
</Unit0>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="5"/>
|
||||
<CodeGeneration>
|
||||
<Checks>
|
||||
<IOChecks Value="True"/>
|
||||
<RangeChecks Value="True"/>
|
||||
<OverflowChecks Value="True"/>
|
||||
<StackChecks Value="True"/>
|
||||
</Checks>
|
||||
<Generate Value="Faster"/>
|
||||
</CodeGeneration>
|
||||
<Other>
|
||||
<CompilerPath Value="$(CompPath)"/>
|
||||
</Other>
|
||||
</CompilerOptions>
|
||||
</CONFIG>
|
||||
137
lcl/tests/test3_1comboboxselect.lpr
Normal file
137
lcl/tests/test3_1comboboxselect.lpr
Normal file
@ -0,0 +1,137 @@
|
||||
{
|
||||
*****************************************************************************
|
||||
* *
|
||||
* This file is part of the Lazarus Component Library (LCL) *
|
||||
* *
|
||||
* See the file COPYING.LCL, included in this distribution, *
|
||||
* for details about the copyright. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* *
|
||||
*****************************************************************************
|
||||
|
||||
LCL Test 3_1
|
||||
|
||||
ComboBox:
|
||||
OnSelect - called when user click on an item on the popup menu.
|
||||
Not called when ItemIndex is set.
|
||||
OnChange - called when user changes text.
|
||||
Not called when ItemIndex is set.
|
||||
Not called when user clicks on an item on the popup menu.
|
||||
}
|
||||
program Test3_1comboboxselect;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
uses
|
||||
Interfaces, FPCAdds, LCLProc, LCLType, Classes, Controls, Forms, TypInfo,
|
||||
LMessages, StdCtrls, Buttons;
|
||||
|
||||
type
|
||||
|
||||
{ TForm1 }
|
||||
|
||||
TForm1 = class(TForm)
|
||||
procedure Button1Click(Sender: TObject);
|
||||
procedure ComboBox1Change(Sender: TObject);
|
||||
procedure ComboBox1Click(Sender: TObject);
|
||||
procedure ComboBox1CloseUp(Sender: TObject);
|
||||
procedure ComboBox1DropDown(Sender: TObject);
|
||||
procedure ComboBox1EditingDone(Sender: TObject);
|
||||
procedure ComboBox1Select(Sender: TObject);
|
||||
public
|
||||
ComboBox1: TComboBox;
|
||||
Button1: TButton;
|
||||
constructor Create(TheOwner: TComponent); override;
|
||||
end;
|
||||
|
||||
{ TForm1 }
|
||||
|
||||
procedure TForm1.Button1Click(Sender: TObject);
|
||||
var
|
||||
NewItemIndex: Integer;
|
||||
begin
|
||||
DebugLn(['TForm1.Button1Click START ComboBox1.ItemIndex=',ComboBox1.ItemIndex]);
|
||||
NewItemIndex:=ComboBox1.ItemIndex+1;
|
||||
if NewItemIndex>=ComboBox1.Items.Count then
|
||||
NewItemIndex:=0;
|
||||
ComboBox1.ItemIndex:=NewItemIndex;
|
||||
DebugLn(['TForm1.Button1Click END ComboBox1.ItemIndex=',ComboBox1.ItemIndex]);
|
||||
end;
|
||||
|
||||
procedure TForm1.ComboBox1Change(Sender: TObject);
|
||||
begin
|
||||
DebugLn(['TForm1.ComboBox1Change ItemIndex=',ComboBox1.ItemIndex]);
|
||||
end;
|
||||
|
||||
procedure TForm1.ComboBox1Click(Sender: TObject);
|
||||
begin
|
||||
DebugLn(['TForm1.ComboBox1Click ItemIndex=',ComboBox1.ItemIndex]);
|
||||
end;
|
||||
|
||||
procedure TForm1.ComboBox1CloseUp(Sender: TObject);
|
||||
begin
|
||||
DebugLn(['TForm1.ComboBox1CloseUp ItemIndex=',ComboBox1.ItemIndex]);
|
||||
end;
|
||||
|
||||
procedure TForm1.ComboBox1DropDown(Sender: TObject);
|
||||
begin
|
||||
DebugLn(['TForm1.ComboBox1DropDown ItemIndex=',ComboBox1.ItemIndex]);
|
||||
end;
|
||||
|
||||
procedure TForm1.ComboBox1EditingDone(Sender: TObject);
|
||||
begin
|
||||
DebugLn(['TForm1.ComboBox1EditingDone ItemIndex=',ComboBox1.ItemIndex]);
|
||||
end;
|
||||
|
||||
procedure TForm1.ComboBox1Select(Sender: TObject);
|
||||
begin
|
||||
DebugLn(['TForm1.ComboBox1Select ItemIndex=',ComboBox1.ItemIndex]);
|
||||
end;
|
||||
|
||||
constructor TForm1.Create(TheOwner: TComponent);
|
||||
begin
|
||||
inherited Create(TheOwner);
|
||||
|
||||
Name:='Form1';
|
||||
Caption:='Title Form1';
|
||||
SetBounds(100,90,350,200);
|
||||
|
||||
ComboBox1:=TComboBox.Create(Self);
|
||||
with ComboBox1 do begin
|
||||
Name:='ComboBox1';
|
||||
SetBounds(10,10,Width,Height);
|
||||
Parent:=Self;
|
||||
OnChange:=@ComboBox1Change;
|
||||
OnClick:=@ComboBox1Click;
|
||||
OnSelect:=@ComboBox1Select;
|
||||
OnCloseUp:=@ComboBox1CloseUp;
|
||||
OnDropDown:=@ComboBox1DropDown;
|
||||
OnEditingDone:=@ComboBox1EditingDone;
|
||||
Items.Add('First');
|
||||
Items.Add('Second');
|
||||
Items.Add('Third');
|
||||
end;
|
||||
|
||||
Button1:=TButton.Create(Self);
|
||||
with Button1 do begin
|
||||
Name:='Button1';
|
||||
SetBounds(10,40,200,Height);
|
||||
Caption:='Change ItemIndex';
|
||||
Parent:=Self;
|
||||
OnClick:=@Button1Click;
|
||||
end;
|
||||
end;
|
||||
|
||||
var
|
||||
Form1: TForm1 = nil;
|
||||
begin
|
||||
Application.Title:='test1_1simpleform1';
|
||||
Application.Initialize;
|
||||
Application.CreateForm(TForm1,Form1);
|
||||
debugln('Form1.Bounds=',dbgs(Form1.BoundsRect));
|
||||
Application.Run;
|
||||
end.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user