You've already forked lazarus-ccr
Minor changes. Capture focus pressing calendar button. Allow paste from contextual menu
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8373 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -15,7 +15,7 @@
|
||||
different kinds of data, floats, dates, etc. while working with
|
||||
db and non db controls."/>
|
||||
<License Value="LGPL with link exception. Read files license-jujiboutils and COPYING.LGPL"/>
|
||||
<Version Major="2" Minor="5"/>
|
||||
<Version Major="2" Minor="5" Release="1"/>
|
||||
<Files Count="36">
|
||||
<Item1>
|
||||
<Filename Value="src/jcontrolutils.pas"/>
|
||||
|
@ -35,7 +35,6 @@ type
|
||||
theValue: TDateTime;
|
||||
fFormat: string;
|
||||
FButton: TSpeedButton;
|
||||
FButtonNeedsFocus: boolean;
|
||||
function GetButtonWidth: integer;
|
||||
function getFormat: string;
|
||||
function getValue: TDateTime;
|
||||
@ -311,6 +310,7 @@ var
|
||||
PopupOrigin: TPoint;
|
||||
ADate: TDateTime;
|
||||
begin
|
||||
Self.SetFocus;
|
||||
PopupOrigin := Self.ControlToScreen(Point(0, Self.Height));
|
||||
if isNull then
|
||||
ADate := now
|
||||
|
@ -37,7 +37,6 @@ type
|
||||
theValue: TDateTime;
|
||||
fFormat: string;
|
||||
FButton: TSpeedButton;
|
||||
FButtonNeedsFocus: boolean;
|
||||
function GetButtonWidth: integer;
|
||||
function getFormat: string;
|
||||
function getValue: TDateTime;
|
||||
@ -331,6 +330,7 @@ var
|
||||
PopupOrigin: TPoint;
|
||||
ADate: TDateTime;
|
||||
begin
|
||||
Self.SetFocus;
|
||||
PopupOrigin := Self.ControlToScreen(Point(0, Self.Height));
|
||||
if isNull then
|
||||
ADate := Now
|
||||
|
@ -35,7 +35,6 @@ type
|
||||
FDataLink: TFieldDataLink;
|
||||
|
||||
FButton: TSpeedButton;
|
||||
FButtonNeedsFocus: boolean;
|
||||
function GetButtonWidth: integer;
|
||||
procedure SetButtonWidth(AValue: integer);
|
||||
procedure WMSetFocus(var Message: TLMSetFocus); message LM_SETFOCUS;
|
||||
@ -332,6 +331,7 @@ var
|
||||
begin
|
||||
if (not Assigned(FDataLink.Field)) or IsReadOnly then
|
||||
exit;
|
||||
Self.SetFocus;
|
||||
PopupOrigin := Self.ControlToScreen(Point(0, Self.Height));
|
||||
if FDataLink.Field.IsNull then
|
||||
ADate := now
|
||||
|
@ -35,7 +35,6 @@ type
|
||||
FDataLink: TFieldDataLink;
|
||||
|
||||
FButton: TSpeedButton;
|
||||
FButtonNeedsFocus: boolean;
|
||||
function GetButtonWidth: integer;
|
||||
procedure SetButtonWidth(AValue: integer);
|
||||
procedure WMSetFocus(var Message: TLMSetFocus); message LM_SETFOCUS;
|
||||
@ -339,6 +338,7 @@ var
|
||||
begin
|
||||
if (not Assigned(FDataLink.Field)) or IsReadOnly then
|
||||
exit;
|
||||
Self.SetFocus;
|
||||
PopupOrigin := Self.ControlToScreen(Point(0, Self.Height));
|
||||
if FDataLink.Field.IsNull then
|
||||
ADate := now
|
||||
|
@ -32,6 +32,7 @@ type
|
||||
TJDBEdit = class(TCustomEdit)
|
||||
private
|
||||
FDataLink: TFieldDataLink;
|
||||
FUpdatingDisplayText: boolean;
|
||||
|
||||
procedure DataChange(Sender: TObject);
|
||||
procedure UpdateData(Sender: TObject);
|
||||
@ -54,6 +55,7 @@ type
|
||||
procedure KeyDown(var Key: word; Shift: TShiftState); override;
|
||||
procedure KeyPress(var Key: char); override;
|
||||
procedure DoEnter; override;
|
||||
procedure Change; override;
|
||||
function GetReadOnly: boolean; override;
|
||||
procedure SetReadOnly(Value: boolean); override;
|
||||
public
|
||||
@ -128,7 +130,11 @@ end;
|
||||
procedure TJDBEdit.DataChange(Sender: TObject);
|
||||
begin
|
||||
if FDataLink.Field <> nil then
|
||||
Caption := FDataLink.Field.AsString
|
||||
begin
|
||||
FUpdatingDisplayText := True;
|
||||
Caption := FDataLink.Field.AsString;
|
||||
FUpdatingDisplayText := False;
|
||||
end
|
||||
else
|
||||
Text := '';
|
||||
end;
|
||||
@ -227,9 +233,7 @@ begin
|
||||
else
|
||||
if Key in [VK_DELETE, VK_BACK] then
|
||||
begin
|
||||
if not IsReadOnly then
|
||||
FDatalink.Edit
|
||||
else
|
||||
if IsReadOnly then
|
||||
Key := VK_UNKNOWN;
|
||||
end;
|
||||
end;
|
||||
@ -246,10 +250,30 @@ begin
|
||||
if not FieldIsEditable(Field) or IsReadOnly then
|
||||
exit;
|
||||
if FDataLink.Field <> nil then
|
||||
begin
|
||||
FUpdatingDisplayText := True;
|
||||
Caption := FDataLink.Field.AsString;
|
||||
FUpdatingDisplayText := False;
|
||||
end;
|
||||
inherited DoEnter;
|
||||
end;
|
||||
|
||||
procedure TJDBEdit.Change;
|
||||
var
|
||||
s: string;
|
||||
apos: integer;
|
||||
begin
|
||||
if (not IsReadOnly) and (not FUpdatingDisplayText) and (not FDataLink.Editing) then
|
||||
begin
|
||||
s := Caption;
|
||||
apos:= SelStart;
|
||||
FDatalink.Edit;
|
||||
Caption := s;
|
||||
SelStart:= apos;
|
||||
end;
|
||||
inherited Change;
|
||||
end;
|
||||
|
||||
function TJDBEdit.GetReadOnly: boolean;
|
||||
begin
|
||||
Result := FDataLink.ReadOnly;
|
||||
@ -270,6 +294,7 @@ begin
|
||||
FDataLink.OnDataChange := @DataChange;
|
||||
FDataLink.OnUpdateData := @UpdateData;
|
||||
FDataLInk.OnActiveChange := @ActiveChange;
|
||||
FUpdatingDisplayText := False;
|
||||
end;
|
||||
|
||||
destructor TJDBEdit.Destroy;
|
||||
@ -289,4 +314,3 @@ begin
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
|
@ -35,7 +35,6 @@ type
|
||||
FDataLink: TFieldDataLink;
|
||||
|
||||
FButton: TSpeedButton;
|
||||
FButtonNeedsFocus: boolean;
|
||||
function GetButtonWidth: integer;
|
||||
procedure SetButtonWidth(AValue: integer);
|
||||
procedure WMSetFocus(var Message: TLMSetFocus); message LM_SETFOCUS;
|
||||
@ -335,6 +334,7 @@ var
|
||||
begin
|
||||
if (not Assigned(FDataLink.Field)) or IsReadOnly then
|
||||
exit;
|
||||
Self.SetFocus;
|
||||
PopupOrigin := Self.ControlToScreen(Point(0, Self.Height));
|
||||
if FDataLink.Field.IsNull then
|
||||
ADate := now
|
||||
|
@ -35,7 +35,6 @@ type
|
||||
FDataLink: TFieldDataLink;
|
||||
|
||||
FButton: TSpeedButton;
|
||||
FButtonNeedsFocus: boolean;
|
||||
function GetButtonWidth: integer;
|
||||
procedure SetButtonWidth(AValue: integer);
|
||||
procedure WMSetFocus(var Message: TLMSetFocus); message LM_SETFOCUS;
|
||||
@ -342,6 +341,7 @@ var
|
||||
begin
|
||||
if (not Assigned(FDataLink.Field)) or IsReadOnly then
|
||||
exit;
|
||||
Self.SetFocus;
|
||||
PopupOrigin := Self.ControlToScreen(Point(0, Self.Height));
|
||||
if FDataLink.Field.IsNull then
|
||||
ADate := now
|
||||
|
@ -32,6 +32,7 @@ type
|
||||
TJDBLabeledEdit = class(TCustomLabeledEdit)
|
||||
private
|
||||
FDataLink: TFieldDataLink;
|
||||
FUpdatingDisplayText: boolean;
|
||||
|
||||
procedure DataChange(Sender: TObject);
|
||||
procedure UpdateData(Sender: TObject);
|
||||
@ -54,6 +55,7 @@ type
|
||||
procedure KeyDown(var Key: word; Shift: TShiftState); override;
|
||||
procedure KeyPress(var Key: char); override;
|
||||
procedure DoEnter; override;
|
||||
procedure Change; override;
|
||||
function GetReadOnly: boolean; override;
|
||||
procedure SetReadOnly(Value: boolean); override;
|
||||
public
|
||||
@ -131,7 +133,11 @@ end;
|
||||
procedure TJDBLabeledEdit.DataChange(Sender: TObject);
|
||||
begin
|
||||
if FDataLink.Field <> nil then
|
||||
Caption := FDataLink.Field.AsString
|
||||
begin
|
||||
FUpdatingDisplayText := True;
|
||||
Caption := FDataLink.Field.AsString;
|
||||
FUpdatingDisplayText := False;
|
||||
end
|
||||
else
|
||||
Text := '';
|
||||
end;
|
||||
@ -230,9 +236,7 @@ begin
|
||||
else
|
||||
if Key in [VK_DELETE, VK_BACK] then
|
||||
begin
|
||||
if not IsReadOnly then
|
||||
FDatalink.Edit
|
||||
else
|
||||
if IsReadOnly then
|
||||
Key := VK_UNKNOWN;
|
||||
end;
|
||||
end;
|
||||
@ -249,10 +253,30 @@ begin
|
||||
if not FieldIsEditable(Field) or IsReadOnly then
|
||||
exit;
|
||||
if FDataLink.Field <> nil then
|
||||
begin
|
||||
FUpdatingDisplayText := True;
|
||||
Caption := FDataLink.Field.AsString;
|
||||
FUpdatingDisplayText := False;
|
||||
end;
|
||||
inherited DoEnter;
|
||||
end;
|
||||
|
||||
procedure TJDBLabeledEdit.Change;
|
||||
var
|
||||
s: string;
|
||||
apos: integer;
|
||||
begin
|
||||
if (not IsReadOnly) and (not FUpdatingDisplayText) and (not FDataLink.Editing) then
|
||||
begin
|
||||
s := Caption;
|
||||
apos:= SelStart;
|
||||
FDatalink.Edit;
|
||||
Caption := s;
|
||||
SelStart:= apos;
|
||||
end;
|
||||
inherited Change;
|
||||
end;
|
||||
|
||||
function TJDBLabeledEdit.GetReadOnly: boolean;
|
||||
begin
|
||||
Result := FDataLink.ReadOnly;
|
||||
@ -273,6 +297,7 @@ begin
|
||||
FDataLink.OnDataChange := @DataChange;
|
||||
FDataLink.OnUpdateData := @UpdateData;
|
||||
FDataLInk.OnActiveChange := @ActiveChange;
|
||||
FUpdatingDisplayText := False;
|
||||
end;
|
||||
|
||||
destructor TJDBLabeledEdit.Destroy;
|
||||
@ -292,4 +317,3 @@ begin
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
|
@ -35,7 +35,6 @@ type
|
||||
theValue: TDateTime;
|
||||
fFormat: string;
|
||||
FButton: TSpeedButton;
|
||||
FButtonNeedsFocus: boolean;
|
||||
function GetButtonWidth: integer;
|
||||
function getFormat: string;
|
||||
function getValue: TDateTime;
|
||||
@ -313,7 +312,8 @@ procedure TJLabeledDateEdit.ShowCalendar(Sender: TObject);
|
||||
var
|
||||
PopupOrigin: TPoint;
|
||||
ADate: TDateTime;
|
||||
begin
|
||||
begin
|
||||
Self.SetFocus;
|
||||
PopupOrigin := Self.ControlToScreen(Point(0, Self.Height));
|
||||
if isNull then
|
||||
ADate := now
|
||||
|
@ -37,7 +37,6 @@ type
|
||||
theValue: TDateTime;
|
||||
fFormat: string;
|
||||
FButton: TSpeedButton;
|
||||
FButtonNeedsFocus: boolean;
|
||||
function GetButtonWidth: integer;
|
||||
function getFormat: string;
|
||||
function getValue: TDateTime;
|
||||
@ -334,6 +333,7 @@ var
|
||||
PopupOrigin: TPoint;
|
||||
ADate: TDateTime;
|
||||
begin
|
||||
Self.SetFocus;
|
||||
PopupOrigin := Self.ControlToScreen(Point(0, Self.Height));
|
||||
if isNull then
|
||||
ADate := Now
|
||||
|
Reference in New Issue
Block a user