Skip to content

Commit

Permalink
Introduce new property for BoldComboBox #21
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bero committed Dec 6, 2024
1 parent cabea23 commit 1e4a148
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Source/BoldComboBox.pas
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)]
Expand Down Expand Up @@ -230,6 +234,7 @@ TBoldComboBox = class(TBoldCustomCombobox)
property OnMeasureItem;
property OnStartDock;
property OnStartDrag;
property UseMouseWheel default False;
{$ENDIF}
end;

Expand Down Expand Up @@ -417,6 +422,7 @@ constructor TBoldCustomComboBox.Create(AOwner: TComponent);
FFont := TFont.Create;
FFont.OnChange := FontChanged;
FColor := clWindow;
FUseMouseWheel := False;
end;

procedure TBoldCustomComboBox.CreateWnd;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 1e4a148

Please sign in to comment.