You've already forked lazarus-ccr
fix locate string values in PopUp forms - now RxDBLookupCombo find values for string fields on type his on keyboard
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1839 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -246,7 +246,7 @@ type
|
|||||||
procedure OnInternalClosePopup(AResult:boolean);virtual;
|
procedure OnInternalClosePopup(AResult:boolean);virtual;
|
||||||
procedure SetEnabled(Value: Boolean); override;
|
procedure SetEnabled(Value: Boolean); override;
|
||||||
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
|
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
|
||||||
procedure KeyPress(var Key: char); override;
|
procedure UTF8KeyPress(var UTF8Key: TUTF8Char); override;
|
||||||
procedure SetParent(AParent: TWinControl); override;
|
procedure SetParent(AParent: TWinControl); override;
|
||||||
procedure DoSetBounds(ALeft, ATop, AWidth, AHeight: Integer); override;
|
procedure DoSetBounds(ALeft, ATop, AWidth, AHeight: Integer); override;
|
||||||
procedure DoPositionButton; virtual;
|
procedure DoPositionButton; virtual;
|
||||||
@ -1294,13 +1294,13 @@ begin
|
|||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TRxCustomDBLookupCombo.KeyPress(var Key: char);
|
procedure TRxCustomDBLookupCombo.UTF8KeyPress(var UTF8Key: TUTF8Char);
|
||||||
begin
|
begin
|
||||||
if not (PopupVisible) and ((Key in [#32..#255]) or (Key=#8)) then
|
if not (PopupVisible) and ((UTF8Key >= #32) or (UTF8Key = #8)) then
|
||||||
ShowList;
|
ShowList;
|
||||||
inherited KeyPress(Key);
|
inherited UTF8KeyPress(UTF8Key);
|
||||||
if PopupVisible then
|
if PopupVisible then
|
||||||
FRxPopUpForm.KeyPress(Key);
|
FRxPopUpForm.UTF8KeyPress(UTF8Key);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TRxCustomDBLookupCombo.SetParent(AParent: TWinControl);
|
procedure TRxCustomDBLookupCombo.SetParent(AParent: TWinControl);
|
||||||
|
@ -51,11 +51,13 @@ type
|
|||||||
FLookupDisplayIndex: integer;
|
FLookupDisplayIndex: integer;
|
||||||
FLookupDisplayField:string;
|
FLookupDisplayField:string;
|
||||||
procedure ClearFind;
|
procedure ClearFind;
|
||||||
procedure FindNextChar(AChar:Char);
|
procedure FindNextChar(UTF8Key: TUTF8Char);
|
||||||
|
// procedure FindNextUTF8Char(UTF8Key: TUTF8Char);
|
||||||
procedure FindPriorChar;
|
procedure FindPriorChar;
|
||||||
procedure SetLookupDisplayIndex(const AValue: integer);
|
procedure SetLookupDisplayIndex(const AValue: integer);
|
||||||
protected
|
protected
|
||||||
procedure KeyPress(var Key: char); dynamic;
|
procedure KeyPress(var Key: char); override;
|
||||||
|
procedure UTF8KeyPress(var UTF8Key: TUTF8Char); override;
|
||||||
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
|
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
|
||||||
property LookupDisplayIndex:integer read FLookupDisplayIndex write SetLookupDisplayIndex;
|
property LookupDisplayIndex:integer read FLookupDisplayIndex write SetLookupDisplayIndex;
|
||||||
end;
|
end;
|
||||||
@ -217,7 +219,7 @@ type
|
|||||||
procedure DoSetFieldsFromString(FL:string);
|
procedure DoSetFieldsFromString(FL:string);
|
||||||
procedure DoSetFieldsFromColList;
|
procedure DoSetFieldsFromColList;
|
||||||
public
|
public
|
||||||
procedure KeyPress(var Key: char); override;
|
procedure UTF8KeyPress(var UTF8Key: TUTF8Char); override;
|
||||||
constructor CreatePopUp(AOwner: TComponent;
|
constructor CreatePopUp(AOwner: TComponent;
|
||||||
APopUpFormOptions:TPopUpFormOptions; AFieldList:string; BtnWidtn:integer);
|
APopUpFormOptions:TPopUpFormOptions; AFieldList:string; BtnWidtn:integer);
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
@ -232,7 +234,7 @@ function ShowRxDBPopUpForm(AControl:TWinControl; ADataSet:TDataSet;
|
|||||||
procedure FillPopupWidth(APopUpFormOptions:TPopUpFormOptions; ARxPopUpForm:TPopUpForm);
|
procedure FillPopupWidth(APopUpFormOptions:TPopUpFormOptions; ARxPopUpForm:TPopUpForm);
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
uses dbutils, math;
|
uses dbutils, math, LCLProc;
|
||||||
|
|
||||||
function ShowRxDBPopUpForm(AControl:TWinControl; ADataSet:TDataSet;
|
function ShowRxDBPopUpForm(AControl:TWinControl; ADataSet:TDataSet;
|
||||||
AOnPopUpCloseEvent:TPopUpCloseEvent; APopUpFormOptions:TPopUpFormOptions;
|
AOnPopUpCloseEvent:TPopUpCloseEvent; APopUpFormOptions:TPopUpFormOptions;
|
||||||
@ -333,10 +335,10 @@ begin
|
|||||||
Invalidate;
|
Invalidate;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TPopUpForm.KeyPress(var Key: char);
|
procedure TPopUpForm.UTF8KeyPress(var UTF8Key: TUTF8Char);
|
||||||
begin
|
begin
|
||||||
inherited KeyPress(Key);
|
inherited UTF8KeyPress(UTF8Key);
|
||||||
FGrid.KeyPress(Key);
|
FGrid.UTF8KeyPress(UTF8Key);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TPopUpForm.GridDblClick(Sender: TObject);
|
procedure TPopUpForm.GridDblClick(Sender: TObject);
|
||||||
@ -808,7 +810,22 @@ begin
|
|||||||
DataSource.DataSet.First;
|
DataSource.DataSet.First;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TPopUpGrid.FindNextChar(AChar: Char);
|
procedure TPopUpGrid.FindNextChar(UTF8Key: TUTF8Char);
|
||||||
|
var
|
||||||
|
F:string;
|
||||||
|
begin
|
||||||
|
FFindLine:=FFindLine + UTF8Key;
|
||||||
|
if DatalinkActive then
|
||||||
|
if DataSetLocateThrough(DataSource.DataSet, FLookupDisplayField, FFindLine, [loCaseInsensitive, loPartialKey]) then
|
||||||
|
begin
|
||||||
|
TPopUpForm(Owner).WControl.Caption:=FFindLine;
|
||||||
|
TPopUpForm(Owner).WControl.Repaint;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
FFindLine:=F;
|
||||||
|
end;
|
||||||
|
{
|
||||||
|
procedure TPopUpGrid.FindNextUTF8Char(UTF8Key: TUTF8Char);
|
||||||
var
|
var
|
||||||
F:string;
|
F:string;
|
||||||
begin
|
begin
|
||||||
@ -822,14 +839,15 @@ begin
|
|||||||
else
|
else
|
||||||
FFindLine:=F;
|
FFindLine:=F;
|
||||||
end;
|
end;
|
||||||
|
}
|
||||||
procedure TPopUpGrid.FindPriorChar;
|
procedure TPopUpGrid.FindPriorChar;
|
||||||
var
|
var
|
||||||
F:string;
|
F:string;
|
||||||
begin
|
begin
|
||||||
if FFindLine = '' then exit;
|
if FFindLine = '' then exit;
|
||||||
F:=FFindLine;
|
F:=FFindLine;
|
||||||
Delete(FFindLine, Length(FFindLine), 1);
|
UTF8Delete(FFindLine, UTF8Length(FFindLine), 1);
|
||||||
|
//Delete(FFindLine, Length(FFindLine), 1);
|
||||||
if DatalinkActive then
|
if DatalinkActive then
|
||||||
if (FFindLine<>'') then
|
if (FFindLine<>'') then
|
||||||
begin
|
begin
|
||||||
@ -876,6 +894,22 @@ begin
|
|||||||
ClearFind;
|
ClearFind;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TPopUpGrid.UTF8KeyPress(var UTF8Key: TUTF8Char);
|
||||||
|
begin
|
||||||
|
inherited UTF8KeyPress(UTF8Key);
|
||||||
|
{ if (Columns[FLookupDisplayIndex].Field.DataType<>ftString) and not (Key in ['0'..'9']) then
|
||||||
|
Exit
|
||||||
|
else}
|
||||||
|
if UTF8Key=#32 then
|
||||||
|
FindNextChar(UTF8Key)
|
||||||
|
else
|
||||||
|
if UTF8Key>#32 then
|
||||||
|
FindNextChar(UTF8Key)
|
||||||
|
else
|
||||||
|
if UTF8Key = #8 then
|
||||||
|
ClearFind;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TPopUpGrid.KeyDown(var Key: Word; Shift: TShiftState);
|
procedure TPopUpGrid.KeyDown(var Key: Word; Shift: TShiftState);
|
||||||
begin
|
begin
|
||||||
if Key = VK_DELETE then
|
if Key = VK_DELETE then
|
||||||
|
Reference in New Issue
Block a user