You've already forked lazarus-ccr
RxFPC:allow mouse wheel on RxDBLookupCombo
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8081 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@@ -246,6 +246,7 @@ type
|
|||||||
procedure KeyValueChanged;
|
procedure KeyValueChanged;
|
||||||
procedure UpdateData;
|
procedure UpdateData;
|
||||||
procedure NeedUpdateData;
|
procedure NeedUpdateData;
|
||||||
|
procedure DoScrollLockup(AForward:Boolean);
|
||||||
protected
|
protected
|
||||||
procedure CalculatePreferredSize(var PreferredWidth, PreferredHeight: integer;
|
procedure CalculatePreferredSize(var PreferredWidth, PreferredHeight: integer;
|
||||||
WithThemeSpace: Boolean); override;
|
WithThemeSpace: Boolean); override;
|
||||||
@@ -269,6 +270,8 @@ type
|
|||||||
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
|
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
|
||||||
procedure CMVisibleChanged(var Msg: TLMessage); message CM_VISIBLECHANGED;
|
procedure CMVisibleChanged(var Msg: TLMessage); message CM_VISIBLECHANGED;
|
||||||
procedure CMEnabledChanged(var Msg: TLMessage); message CM_ENABLEDCHANGED;
|
procedure CMEnabledChanged(var Msg: TLMessage); message CM_ENABLEDCHANGED;
|
||||||
|
function DoMouseWheelDown(Shift: TShiftState; MousePos: TPoint): Boolean; override;
|
||||||
|
function DoMouseWheelUp(Shift: TShiftState; MousePos: TPoint): Boolean; override;
|
||||||
|
|
||||||
procedure MouseEnter; override;
|
procedure MouseEnter; override;
|
||||||
procedure MouseLeave; override;
|
procedure MouseLeave; override;
|
||||||
@@ -1193,6 +1196,31 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TRxCustomDBLookupCombo.DoScrollLockup(AForward: Boolean);
|
||||||
|
begin
|
||||||
|
if FLookupDataLink.Active and FDataLink.Active and not (PopupVisible or ReadOnly) then
|
||||||
|
begin
|
||||||
|
FDataLink.Edit;
|
||||||
|
if not FDataField.IsNull then
|
||||||
|
begin
|
||||||
|
If not FLocateObject.Locate(FLookupField, FDataField.AsString, true, false) then FLookupDataLink.DataSet.First;
|
||||||
|
if AForward then
|
||||||
|
begin
|
||||||
|
if not FLookupDataLink.DataSet.EOF then
|
||||||
|
FLookupDataLink.DataSet.Next;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
if not FLookupDataLink.DataSet.BOF then
|
||||||
|
FLookupDataLink.DataSet.Prior;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
Self.NeedUpdateData;
|
||||||
|
DoSelect;
|
||||||
|
KeyValueChanged;
|
||||||
|
end
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TRxCustomDBLookupCombo.CalculatePreferredSize(var PreferredWidth,
|
procedure TRxCustomDBLookupCombo.CalculatePreferredSize(var PreferredWidth,
|
||||||
PreferredHeight: integer; WithThemeSpace: Boolean);
|
PreferredHeight: integer; WithThemeSpace: Boolean);
|
||||||
var
|
var
|
||||||
@@ -1302,22 +1330,7 @@ begin
|
|||||||
begin
|
begin
|
||||||
if (Key in [VK_UP, VK_DOWN]) and (Shift = []) then
|
if (Key in [VK_UP, VK_DOWN]) and (Shift = []) then
|
||||||
begin
|
begin
|
||||||
FDataLink.Edit;
|
DoScrollLockup(Key = VK_DOWN);
|
||||||
if not FDataField.IsNull then
|
|
||||||
begin
|
|
||||||
//FLocateObject.Locate(FLookupField, FDataField.AsString, true, false);
|
|
||||||
If not FLocateObject.Locate(FLookupField, FDataField.AsString, true, false) then FLookupDataLink.DataSet.First;
|
|
||||||
case Key of
|
|
||||||
VK_UP: if not FLookupDataLink.DataSet.BOF then
|
|
||||||
FLookupDataLink.DataSet.Prior;
|
|
||||||
VK_DOWN: if not FLookupDataLink.DataSet.EOF then
|
|
||||||
FLookupDataLink.DataSet.Next;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
//FDataLink.UpdateRecord; -- no need more...
|
|
||||||
Self.NeedUpdateData;
|
|
||||||
DoSelect;
|
|
||||||
KeyValueChanged;
|
|
||||||
Key:=0;
|
Key:=0;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -1434,6 +1447,22 @@ begin
|
|||||||
FButton.Enabled:=Enabled;
|
FButton.Enabled:=Enabled;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TRxCustomDBLookupCombo.DoMouseWheelDown(Shift: TShiftState;
|
||||||
|
MousePos: TPoint): Boolean;
|
||||||
|
begin
|
||||||
|
Result:=inherited DoMouseWheelDown(Shift, MousePos);
|
||||||
|
if (not Result) and (Shift = []) then
|
||||||
|
DoScrollLockup(true);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TRxCustomDBLookupCombo.DoMouseWheelUp(Shift: TShiftState;
|
||||||
|
MousePos: TPoint): Boolean;
|
||||||
|
begin
|
||||||
|
Result:=inherited DoMouseWheelUp(Shift, MousePos);
|
||||||
|
if (not Result) and (Shift = []) then
|
||||||
|
DoScrollLockup(false);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TRxCustomDBLookupCombo.MouseEnter;
|
procedure TRxCustomDBLookupCombo.MouseEnter;
|
||||||
begin
|
begin
|
||||||
inherited MouseEnter;
|
inherited MouseEnter;
|
||||||
|
Reference in New Issue
Block a user