fixed focussing modal forms on gtk intf

git-svn-id: trunk@7221 -
This commit is contained in:
mattias 2005-06-03 20:58:23 +00:00
parent 901d33b48f
commit 36fcecd067
7 changed files with 65 additions and 15 deletions

View File

@ -2112,7 +2112,7 @@ resourcestring
+'create package source directory %s%s%s%sfor package %s.';
lisPkgMangUnableToLoadPackage = 'Unable to load package';
lisPkgMangUnableToOpenThePackage = 'Unable to open the package %s%s%s.%'
+'sThis package was marked for for installation.';
+'sThis package was marked for installation.';
lisPkgMangInvalidPackageName2 = 'Invalid Package Name';
lisPkgMangThePackageNameOfTheFileIsInvalid = 'The package name %s%s%s of%'
+'sthe file %s%s%s is invalid.';

View File

@ -1344,7 +1344,7 @@ begin
lDefaultControl := Form.ActiveDefaultControl;
if lDefaultControl = nil then
lDefaultControl := Form.DefaultControl;
if (lDefaultControl <> nil)
if (lDefaultControl <> nil)
and ((lDefaultControl.Parent = nil) or (lDefaultControl.Parent.CanFocus))
and lDefaultControl.Enabled and lDefaultControl.Visible then
begin
@ -1466,6 +1466,9 @@ end;
{ =============================================================================
$Log$
Revision 1.120 2005/06/03 20:58:23 mattias
fixed focussing modal forms on gtk intf
Revision 1.119 2005/05/03 16:52:29 mattias
fixed triggering TDataModule, and improved parent search for new designer controls. from Jesus

View File

@ -157,7 +157,7 @@ end;
procedure TCustomButton.ExecuteDefaultAction;
begin
if FActive then
if FActive or FDefault then
Click;
end;
@ -296,6 +296,9 @@ end;
{ =============================================================================
$Log$
Revision 1.46 2005/06/03 20:58:23 mattias
fixed focussing modal forms on gtk intf
Revision 1.45 2005/04/27 12:37:28 micha
implement/fix button/label shortcut accelchar handling

View File

@ -93,6 +93,7 @@ var
begin
if (Key=VK_Escape) then
ModalResult := -1;
if (Key=VK_LEFT) or (Key=VK_RIGHT) then begin
// focus the next button to the left or right
@ -339,6 +340,7 @@ begin
and (TCustomBitBtn(Components[i]).Default) then
begin
ActiveControl:=TCustomBitBtn(Components[i]);
DefaultControl:=TCustomBitBtn(Components[i]);
break;
end;
end;
@ -745,6 +747,9 @@ end;
{
$Log$
Revision 1.20 2005/06/03 20:58:23 mattias
fixed focussing modal forms on gtk intf
Revision 1.19 2005/01/28 10:48:28 mattias
fixed compilation

View File

@ -491,7 +491,7 @@ begin
if GtkWidgetIsA(Widget, gtk_window_get_type) then
Mess.ActiveWindow:=HWnd(PGTKWindow(Widget)^.focus_widget);
Mess.Result := 0;
DeliverPostMessage(Data, Mess);
DeliverMessage(Data, Mess); // send message directly (not Post)
Result := CallBackDefaultReturn;
end;
@ -518,7 +518,7 @@ begin
UpdateMouseCaptureControl;
Mess.Msg := LM_DEACTIVATE;
DeliverPostMessage(Data, Mess);
DeliverMessage(Data, Mess);
Result := CallBackDefaultReturn;
end;
@ -2986,6 +2986,9 @@ end;
{ =============================================================================
$Log$
Revision 1.279 2005/06/03 20:58:23 mattias
fixed focussing modal forms on gtk intf
Revision 1.278 2005/04/04 11:57:47 mattias
reduced gtk2 warnings from Danny Milosavljevic

View File

@ -211,7 +211,18 @@ begin
if GdkWindow<>nil then begin
AForm:=TCustomForm(GetLCLObject(PgtkWidget(hwnd)));
if (AForm<>nil) and (AForm is TCustomForm) and (AForm.Parent=nil) then
begin
if Screen.CustomFormZIndex(AForm)<Screen.GetCurrentModalFormZIndex then
begin
debugln('TGtkWidgetSet.BringWindowToTop Form=',DbgSName(AForm),
' can not be raised, because ',
DbgSName(Screen.GetCurrentModalForm),
' is modal and above.');
Result:=false;
exit;
end;
Screen.MoveFormToZFront(AForm);
end;
{$IFDEF DebugGDKTraps}
BeginGDKErrorTrap;
{$ENDIF}
@ -229,7 +240,8 @@ begin
// which could be undesirable.
// check if the window is on all desktops or is on the current desktop
if (WindowDesktop < 0) or (WindowDesktop = GDK_GET_CURRENT_DESKTOP) then begin
if (WindowDesktop < 0) or (WindowDesktop = GDK_GET_CURRENT_DESKTOP) then
begin
GDK_WINDOW_ACTIVATE(FormWindow);
end
else begin
@ -7870,18 +7882,23 @@ end;
The SetFocus function sets the keyboard focus to the specified window
------------------------------------------------------------------------------}
function TGtkWidgetSet.SetFocus(hWnd: HWND): HWND;
{off $DEFINE VerboseFocus}
var
Widget, TopLevel, ImplWidget, NewFocusWidget: PGtkWidget;
WinWidgetInfo: PWinWidgetInfo;
{$IfDef VerboseFocus}
LCLObject, AWinControl: TWinControl;
NewTopLevel: PGtkWidget;
{$EndIf}
NewTopLevelWidget: PGtkWidget;
NewTopLevelObject: TObject;
NewForm: TCustomForm;
begin
if hWnd=0 then exit;
Widget:=PGtkWidget(hWnd);
{$IfDef VerboseFocus}
DebugLn('');
write('[TGtkWidgetSet.SetFocus] A hWnd=',GetWidgetDebugReport(Widget));
writeln('[TGtkWidgetSet.SetFocus] A hWnd=',GetWidgetDebugReport(Widget));
LCLObject:=TWinControl(GetLCLObject(Widget));
{$EndIf}
if hwnd = 0 then begin
@ -7918,6 +7935,20 @@ begin
write(' LCLParent=nil');
DebugLn('');
{$EndIf}
NewTopLevelObject:=GetNearestLCLObject(TopLevel);
if (NewTopLevelObject is TCustomForm) then begin
NewForm:=TCustomForm(NewTopLevelObject);
if Screen.GetCurrentModalFormZIndex>Screen.CustomFormZIndex(NewForm) then
begin
// there is a modal form above -> focus forbidden
{$IfDef VerboseFocus}
DebugLn(' there is a modal form above -> focus forbidden');
{$EndIf}
exit;
end;
end;
if (NewFocusWidget=nil)
and GtkWidgetIsA(Widget, gtk_combo_get_type) then begin
// handle is a gtk combo
@ -7932,7 +7963,7 @@ begin
if (WinWidgetInfo<>nil) then begin
ImplWidget:= WinWidgetInfo^.CoreWidget;
if ImplWidget <> nil then begin
// handle has a ImplementationWidget
// handle has an ImplementationWidget
if GtkWidgetIsA(ImplWidget, gtk_list_get_type) then begin
{$IfDef VerboseFocus}
DebugLn(' E using list');
@ -7959,7 +7990,7 @@ begin
{$EndIf}
end;
{$IfDef VerboseFocus}
write(' G NewFocusWidget=',DbgS(NewFocusWidget));
write(' G NewFocusWidget=',DbgS(NewFocusWidget),' ',DbgSName(GetNearestLCLObject(NewFocusWidget)));
write(' WidVisible=',GTK_WIDGET_VISIBLE(PGtkWidget(NewFocusWidget)));
write(' WidRealized=',GTK_WIDGET_REALIZED(PGtkWidget(NewFocusWidget)));
write(' WidMapped=',GTK_WIDGET_MAPPED(PGtkWidget(NewFocusWidget)));
@ -7971,7 +8002,7 @@ begin
if (PGtkWindow(TopLevel)^.Focus_Widget<>NewFocusWidget)
then begin
{$IfDef VerboseFocus}
DebugLn(' H SETTING NewFocusWidget=',DbgS(NewFocusWidget));
DebugLn(' H SETTING NewFocusWidget=',dbgs(NewFocusWidget),' ',DbgSName(GetNearestLCLObject(NewFocusWidget)));
{$EndIf}
gtk_window_set_focus(PGtkWindow(TopLevel),NewFocusWidget);
{$IfDef VerboseFocus}
@ -7984,18 +8015,19 @@ begin
NewFocusWidget:=Widget;
end;
if (NewFocusWidget <> nil) and not gtk_widget_has_focus(NewFocusWidget) then begin
if (NewFocusWidget <> nil) and not gtk_widget_has_focus(NewFocusWidget) then
begin
// grab the focus to the parent window
NewTopLevelWidget := gtk_widget_get_toplevel(NewFocusWidget);
if (Screen<>nil)
and (Screen.FocusedForm<>nil)
and (fsModal in Screen.FocusedForm.FormState)
and (GetNearestLCLObject(TopLevel)<>Screen.FocusedForm) then begin
and (GetNearestLCLObject(NewTopLevelWidget)<>Screen.GetCurrentModalForm)
then begin
{$IFDEF VerboseFocus}
DebugLn('[TGtkWidgetSet.SetFocus] there is a modal form -> not grabbing');
{$ENDIF}
end else begin
{$IfDef VerboseFocus}
DebugLn(' J Grabbing focus');
DebugLn(' J Grabbing focus ',GetWidgetDebugReport(NewFocusWidget));
{$EndIf}
gtk_widget_grab_focus(NewFocusWidget);
end;
@ -8987,6 +9019,9 @@ end;
{ =============================================================================
$Log$
Revision 1.421 2005/06/03 20:58:23 mattias
fixed focussing modal forms on gtk intf
Revision 1.420 2005/05/21 15:58:44 mattias
implemented right justification for menuitems for winapi intf from Martin Smat

View File

@ -527,6 +527,7 @@ begin
gtk_window_set_modal(GtkWindow, true);
gtk_widget_show(PGtkWidget(GtkWindow));
GDK_WINDOW_ACTIVATE(PGdkWindowPrivate(PGtkWidget(GtkWindow)^.window));
{$IFDEF VerboseTransient}
DebugLn('TGtkWidgetSet.ShowModal ',Sender.ClassName);