summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/gui/gui_combobox.pas31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/gui/gui_combobox.pas b/src/gui/gui_combobox.pas
index 3b88ae28..f0ebe833 100644
--- a/src/gui/gui_combobox.pas
+++ b/src/gui/gui_combobox.pas
@@ -58,6 +58,8 @@ uses
type
+ { TfpgBaseComboBox }
+
TfpgBaseComboBox = class(TfpgWidget)
private
FDropDownCount: integer;
@@ -86,6 +88,8 @@ type
end;
+ { TfpgAbstractComboBox }
+
TfpgAbstractComboBox = class(TfpgBaseComboBox)
private
FInternalBtnRect: TfpgRect;
@@ -105,6 +109,7 @@ type
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 HandleMouseScroll(x, y: integer; shiftstate: TShiftState; delta: smallint); override;
procedure HandleResize(awidth, aheight: TfpgCoord); override;
procedure HandlePaint; override;
procedure PaintInternalButton; virtual;
@@ -496,6 +501,32 @@ begin
PaintInternalButton;
end;
+procedure TfpgAbstractComboBox.HandleMouseScroll(x, y: integer;
+ shiftstate: TShiftState; delta: smallint);
+var
+ NewIndex: Integer;
+begin
+ if (FDropDown <> nil) and FDropDown.Visible then
+ Exit;
+ if Items.Count < 1 then
+ Exit;
+
+ NewIndex := FocusItem + Delta;
+
+ if NewIndex > Items.Count then
+ NewIndex := Items.Count;
+
+ if NewIndex < 1 then
+ NewIndex := 1;
+
+ if NewIndex <> FocusItem then
+ begin
+ FocusItem := NewIndex;
+ RePaint;
+ end;
+
+end;
+
procedure TfpgAbstractComboBox.HandleResize(awidth, aheight: TfpgCoord);
begin
inherited HandleResize(awidth, aheight);