summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorgraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2008-03-14 10:24:48 +0000
committergraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2008-03-14 10:24:48 +0000
commit5527412a2a275af327c94d9bcded29c9c45543d7 (patch)
tree1dfab79c16eb70d1fc69fc4edf6aa060ec6e8ec3 /src
parent19e38489164dbd200277b17d3e2679a5e4549f81 (diff)
downloadfpGUI-5527412a2a275af327c94d9bcded29c9c45543d7.tar.xz
* Applied ComboBox patch from Antonio to allow Up and Down keys to change selected item.
Diffstat (limited to 'src')
-rw-r--r--src/gui/gui_combobox.pas40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/gui/gui_combobox.pas b/src/gui/gui_combobox.pas
index 1588882e..42828afa 100644
--- a/src/gui/gui_combobox.pas
+++ b/src/gui/gui_combobox.pas
@@ -58,6 +58,8 @@ uses
type
+ { TfpgAbstractComboBox }
+
TfpgAbstractComboBox = class(TfpgWidget)
private
FDropDownCount: integer;
@@ -84,6 +86,7 @@ type
procedure SetText(const AValue: string); virtual;
procedure SetHeight(const AValue: TfpgCoord); override;
procedure SetWidth(const AValue: TfpgCoord); override;
+ procedure HandleKeyPress(var keycode: word; var shiftstate: TShiftState; var consumed: boolean); override;
procedure HandleLMouseDown(x, y: integer; shiftstate: TShiftState); override;
procedure HandleLMouseUp(x, y: integer; shiftstate: TShiftState); override;
procedure HandleResize(awidth, aheight: TfpgCoord); override;
@@ -363,6 +366,43 @@ begin
RePaint;
end;
+procedure TfpgAbstractComboBox.HandleKeyPress(var keycode: word; var shiftstate: TShiftState; var consumed: boolean);
+var
+ hasChanged: boolean;
+begin
+ inherited HandleKeyPress(keycode, shiftstate, consumed);
+ hasChanged := False;
+ consumed := True;
+ case keycode of
+
+ keyDown:
+ begin
+ FocusItem := FocusItem + 1;
+ hasChanged := True;
+ end;
+
+ keyUp:
+ begin
+ FocusItem := FocusItem - 1;
+ hasChanged := True;
+ end;
+
+ else
+ begin
+ Consumed := False;
+ end;
+ end;
+
+ if consumed then
+ RePaint
+ else
+ inherited;
+
+ if hasChanged then
+ if Assigned(FOnChange) then
+ FOnChange(self);
+end;
+
procedure TfpgAbstractComboBox.CalculateInternalButtonRect;
begin
FInternalBtnRect.SetRect(Width - Min(Height, 20), 2, Min(Height, 20)-2, Height-4);