Button.Default now sets focus

git-svn-id: trunk@3734 -
This commit is contained in:
mattias 2002-12-25 11:53:47 +00:00
parent 17f2aeb9bc
commit 32b0f7ae9b
3 changed files with 51 additions and 26 deletions

View File

@ -1,3 +1,5 @@
// included by buttons.pp
{
*****************************************************************************
* *
@ -36,8 +38,8 @@ end;
{------------------------------------------------------------------------------}
destructor TBitbtn.Destroy;
Begin
FCanvas.Free;
FGlyph.Free;
FreeThenNil(FCanvas);
FreeThenNil(FGlyph);
inherited Destroy;
end;
@ -47,12 +49,12 @@ var
Begin
if FKind = bkClose then Begin
Form := GetParentForm(Self);
if Form <> nil then Form.Close
else
inherited click;
end
else
inherited Click;
if Form <> nil then begin
Form.Close;
exit;
end;
end;
inherited Click;
End;
Function TBitbtn.GetGlyph : TBitmap;
@ -102,11 +104,8 @@ Begin
Caption := BitBtnCaption[fKind];
ModalResult := BitBtnModalResults[Value];
if (FKind = bkOK) or (FKind = bkYes) then
Default := True
else
Default := False;
if not (csLoading in ComponentState) then
Default := FKind in [bkOk,bkYes];
end;
Procedure TBitBtn.SetLayout(Value : TButtonLayout);
@ -117,7 +116,6 @@ Begin
CNSendMessage(LM_LAYOUTCHANGED,Self,nil);
end;
Procedure TBitBtn.SetSpacing(Value : Integer);
Begin
if (FSpacing = Value) or (Value < 0) then Exit;
@ -127,5 +125,5 @@ Begin
CNSendMessage(LM_LAYOUTCHANGED,Self,nil);
end;
// included by buttons.pp

View File

@ -48,24 +48,39 @@ end;
procedure TButton.CreateWnd;
begin
inherited CreateWnd;
If HandleAllocated then
SetText(Caption);//To ensure shortcut is set
SetText(Caption);//To ensure shortcut is set
DoSendBtnDefault;
end;
{------------------------------------------------------------------------------
procedure TButton.DoSendBtnDefault;
------------------------------------------------------------------------------}
procedure TButton.DoSendBtnDefault;
begin
if HandleAllocated then
CNSendMessage(LM_BTNDEFAULT_CHANGED,Self,nil);
end;
{------------------------------------------------------------------------------
procedure TButton.SetParent(AParent: TWinControl);
------------------------------------------------------------------------------}
procedure TButton.SetParent(AParent: TWinControl);
begin
if Parent=AParent then exit;
inherited SetParent(AParent);
DoSendBtnDefault;
end;
{------------------------------------------------------------------------------
Method: TButton.SetDefault
Params: Value
Returns: Nothing
------------------------------------------------------------------------------}
procedure TButton.SetDefault(Value : Boolean);
begin
if FDefault = Value then Exit;
FDefault := Value;
if HandleAllocated then
CNSendMessage(LM_BTNDEFAULT_CHANGED,Self,nil);
DoSendBtnDefault;
End;
{------------------------------------------------------------------------------
@ -150,6 +165,9 @@ end;
{ =============================================================================
$Log$
Revision 1.11 2002/12/25 11:53:47 mattias
Button.Default now sets focus
Revision 1.10 2002/09/06 15:57:34 lazarus
MG: fixed notebook client area, send messages and minor bugs

View File

@ -255,13 +255,19 @@ procedure TCustomForm.WMShowWindow(var message: TLMShowWindow);
const
SHOW_TEXT: array[Boolean] of string = ('Hide', 'Show');
begin
if (fsShowing in FFormState) then exit;
Assert(False, Format('Trace: [TCustomForm.LMShowWindow] %s %s', [SHOW_TEXT[Message.Show], ClassName]));
Include(FFormState, fsShowing);
try
if Message.Show
then DoShow
else DoHide;
if Message.Show then begin
if FActiveControl<>nil then begin
//writeln('TCustomForm.WMShowWindow ',FActiveControl.Name,':',FActiveControl.ClassName);
LCLLinux.SetFocus(FActiveControl.Handle);
end;
DoShow;
end else begin
DoHide;
end;
finally
Exclude(FFormState, fsShowing);
end;
@ -1177,6 +1183,9 @@ end;
{ =============================================================================
$Log$
Revision 1.77 2002/12/25 11:53:47 mattias
Button.Default now sets focus
Revision 1.76 2002/12/25 10:21:05 mattias
made Form.Close more Delphish, added some windows compatibility functions