summaryrefslogtreecommitdiff
path: root/src/gui/gui_editcombo.pas
diff options
context:
space:
mode:
authorgraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2008-02-25 09:14:10 +0000
committergraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2008-02-25 09:14:10 +0000
commit450da5d28e0173db8484a0be094bfc23872ecedc (patch)
tree46b3f75a9e3d9bf85911d7a66fa9783ada0d5963 /src/gui/gui_editcombo.pas
parenteae9a03adbefd12de7881d0cb933f4d2330d3b11 (diff)
downloadfpGUI-450da5d28e0173db8484a0be094bfc23872ecedc.tar.xz
* Scrolling the dropdown to the end, it doesn't display the last item.
Example: in a un-filtered list the name Yves doesn't get displayed. * The user couldn't select the last item in the dropdown list (filtered or not). Using the keyboard or mouse, selecting the last item didn't close the combobox and select the item. * InternalListBoxSelect() has some bugs. Items property is 0-based but FocusItem is 1-based.
Diffstat (limited to 'src/gui/gui_editcombo.pas')
-rw-r--r--src/gui/gui_editcombo.pas32
1 files changed, 21 insertions, 11 deletions
diff --git a/src/gui/gui_editcombo.pas b/src/gui/gui_editcombo.pas
index 7e8ffc85..00fd11c3 100644
--- a/src/gui/gui_editcombo.pas
+++ b/src/gui/gui_editcombo.pas
@@ -61,7 +61,8 @@ uses
gfx_popupwindow;
type
- TAllowNew = (anNo,anYes,anAsk);
+ TAllowNew = (anNo, anYes, anAsk);
+
TfpgAbstractEditCombo = class(TfpgWidget)
private
@@ -109,6 +110,7 @@ type
procedure HandlePaint; override;
procedure PaintInternalButton; virtual;
property DropDownCount: integer read FDropDownCount write SetDropDownCount default 8;
+ // property is 0-based
property Items: TStringList read FItems; {$Note Make this read/write}
// property is 1-based
property FocusItem: integer read FFocusItem write SetFocusItem;
@@ -349,11 +351,11 @@ begin
begin
FreeAndNil(FDropDown);
OriginalFocusRoot := FocusRootWidget;
- FDropDown := TDropDownWindow.Create(nil);
+ FDropDown := TDropDownWindow.Create(nil);
ddw := TDropDownWindow(FDropDown);
ddw.Width := Width;
- ddw.CallerWidget := self;
- ddw.ListBox.OnSelect := @InternalListBoxSelect;
+ ddw.CallerWidget := self;
+ ddw.ListBox.OnSelect := @InternalListBoxSelect;
// Assign combobox text items to internal listbox
if FAutoCompletion then
@@ -371,7 +373,7 @@ begin
rowcount := FDropDownCount;
if rowcount < 1 then
rowcount := 1;
- ddw.Height := (ddw.ListBox.RowHeight * rowcount) + 4;
+ ddw.Height := (ddw.ListBox.RowHeight * rowcount) + 4;
// set default focusitem
ddw.ListBox.FocusItem := FFocusItem;
@@ -396,9 +398,17 @@ end;
procedure TfpgAbstractEditCombo.InternalListBoxSelect(Sender: TObject);
var
- msgp: TfpgMessageParams;
+ i: Integer;
begin
- FFocusItem := TDropDownWindow(FDropDown).ListBox.FocusItem;
+ for i := 0 to Items.Count-1 do
+ begin
+ // Items is 0-based and FocusItem is 1-based
+ if Items[i]= TDropDownWindow(FDropDown).ListBox.Items[TDropDownWindow(FDropDown).ListBox.FocusItem-1] then
+ begin
+ FFocusItem := i+1;
+ Break;
+ end;
+ end;
FDropDown.Close;
if HasHandle then
@@ -442,7 +452,7 @@ begin
begin
for i := 0 to FItems.Count - 1 do
begin
- if SameText(UTF8Copy(FItems.Strings[i],1,UTF8Length(AVAlue)), AValue) then
+ if SameText(UTF8Copy(FItems.Strings[i], 1, UTF8Length(AVAlue)), AValue) then
begin
SetFocusItem(i+1); // our FocusItem is 1-based. TStringList is 0-based.
Break;
@@ -484,9 +494,9 @@ var
s: string;
prevval: string;
begin
- prevval := FText;
- s := UTF8Encode(AText);
- consumed := False;
+ prevval := FText;
+ s := UTF8Encode(AText);
+ consumed := False;
// Handle only printable characters
// Note: This is not UTF-8 compliant!