From 1e4a148fc20eb69a8d38b77a48b766bf62a1b6ec Mon Sep 17 00:00:00 2001 From: Roland Bengtsson Date: Fri, 6 Dec 2024 23:08:38 +0200 Subject: [PATCH] Introduce new property for BoldComboBox #21 New property TBoldComboBox.UseMouseWheel: Boolean is introduced to make it possible to control handling in case mouse wheel is used over a boldcombobox control. Before that change using mouse wheel over a bold combo box directly changed the selected value. This could lead to accidentally changing of values. --- Source/BoldComboBox.pas | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Source/BoldComboBox.pas b/Source/BoldComboBox.pas index 431a4e4..f230a86 100644 --- a/Source/BoldComboBox.pas +++ b/Source/BoldComboBox.pas @@ -68,6 +68,7 @@ TBoldCustomComboBox = class(TCustomComboBox, IBoldValidateableComponent, IBold fProcessingClick: Integer; fOnSelectChangedIsCalled:Boolean; fAutoSearch: boolean; + FUseMouseWheel: Boolean; function GetBoldHandle: TBoldElementHandle; procedure SetBoldHandle(value: TBoldElementHandle); function GetFollower: TBoldFOllower; @@ -117,6 +118,8 @@ TBoldCustomComboBox = class(TCustomComboBox, IBoldValidateableComponent, IBold function GetVariableList: TBoldExternalVariableList; function GetExpression: TBoldExpression; protected + function DoMouseWheel(Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint): Boolean; override; + function HandleApplyException(E: Exception; Elem: TBoldElement; var discard: Boolean): boolean; procedure Change; override; function ComboAllowsTextEditing(BoldProperties: TBoldStringFollowerController; Follower: TBoldFollower): Boolean; virtual; @@ -160,6 +163,7 @@ TBoldCustomComboBox = class(TCustomComboBox, IBoldValidateableComponent, IBold destructor Destroy; override; procedure DragDrop(Source: TObject; X, Y: Integer); override; property SelectedElement: TBoldElement read GetSelectedElement; + property UseMouseWheel: Boolean read FUseMouseWheel write FUseMouseWheel; end; [ComponentPlatformsAttribute (pidWin32 or pidWin64)] @@ -230,6 +234,7 @@ TBoldComboBox = class(TBoldCustomCombobox) property OnMeasureItem; property OnStartDock; property OnStartDrag; + property UseMouseWheel default False; {$ENDIF} end; @@ -417,6 +422,7 @@ constructor TBoldCustomComboBox.Create(AOwner: TComponent); FFont := TFont.Create; FFont.OnChange := FontChanged; FColor := clWindow; + FUseMouseWheel := False; end; procedure TBoldCustomComboBox.CreateWnd; @@ -448,6 +454,18 @@ procedure TBoldCustomComboBox.DoEndDrag(Target: TObject; X, Y: Integer); inherited DoEndDrag(Target, X, Y); end; +function TBoldCustomComboBox.DoMouseWheel(Shift: TShiftState; + WheelDelta: Integer; MousePos: TPoint): Boolean; +begin + if FUseMouseWheel then + begin + Result := inherited; + end else + begin + Result := True; + end; +end; + procedure TBoldCustomComboBox.DoStartDrag(var DragObject: TDragObject); begin BoldProperties.StartDrag(Follower);