active
This commit is contained in:
JianjunLiu 2022-12-22 13:47:45 +08:00
parent 05ae594b93
commit 5c87f678d6
4 changed files with 153 additions and 81 deletions

View File

@ -1073,7 +1073,7 @@ type TFTSLScriptMemo = class(TFTSLScriptcustomMemo)
begin
inherited;
end
function SetFocus();
function SetFocus();override;
begin
global g_script_can_set_not_focus;
if g_script_can_set_not_focus then return ;

View File

@ -4502,6 +4502,11 @@ type tapplicationwindow=class(TWinControl)
function DoCnNotify(o,e);override;
begin
end
private
function setactivecontrol(ctl);virtual;
begin
end
end
type TImageListDrawStyle = class()

View File

@ -16,6 +16,7 @@ type TWinControl = class(tcontrol)
//__wstylestruct; //样式消息结构体
__clientsize; //客户区大小
//__oldclientsize; //旧客户区大小
factivated;
FClientleft;
FClientTop;
FClientWdith;
@ -221,6 +222,7 @@ type TWinControl = class(tcontrol)
nv := v?true:false;
if nv <> FWsPopUp then
begin
factivated := false;
FWsPopUp := nv;
if HandleAllocated()then RecreateWnd();
end
@ -846,7 +848,14 @@ type TWinControl = class(tcontrol)
end
function WMACTIVATE(o,e):WM_ACTIVATE;virtual;
begin
factivated := e.wparam;
CallMessgeFunction(OnActivate,o,e);
if e.skip then return ;
defaulthandler(e);
if factivated and ContainsControl(factivecontrol) then
begin
factivecontrol.SetFocus();
end
end
function GetClientRect();override;
begin
@ -910,6 +919,7 @@ type TWinControl = class(tcontrol)
function WMNCDESTROY(o,e):WM_NCDESTROY;virtual;
begin
FHandle := nil;
factivated := false;
for i := 0 to FControls.count-1 do
begin
item := FControls[i];
@ -1642,11 +1652,19 @@ type TWinControl = class(tcontrol)
**}
if HandleAllocated()then return _wapi.UpdateWindow(self.Handle);
end
function SetFocus();
function SetFocus();virtual;
begin
if HandleAllocated()then
begin
_wapi.SetFocus(self.Handle);
r := _wapi.SetFocus(self.Handle);
return r;
end
end
function setactive(); virtual;
begin
if WsPopUp and HandleAllocated() then
begin
_wapi.SetActiveWindow(self.Handle);
end
end
function DescendantHwnd(hwnd);
@ -1769,9 +1787,10 @@ type TWinControl = class(tcontrol)
return r;
end
end
function ContainsControl(Control:TControl):bool;
function ContainsControl(Control_:TControl):bool;//°üº¬¿Ø¼þ
begin
while(Control <> nil)and(Control <> Self) do Control := Control.Parent;
Control := Control_;
while(Control is class(TWinControl)) and(Control <> Self) do Control := Control.Parent;
return Control=Self;
end
function create(owner);override; //type_twinctrol
@ -1824,6 +1843,7 @@ type TWinControl = class(tcontrol)
ImageList := nil;
FonSetFocus := nil;
FonKillFocus := nil;
factivecontrol := nil;
inherited;
end
function RecreateWnd();virtual;
@ -1861,6 +1881,14 @@ type TWinControl = class(tcontrol)
InitializeWnd();
if HandleAllocated()then ControlCreateWnd();
end
function Notification(ac,op);override;
begin
if op=opRecycling and ac=factivecontrol then
begin
factivecontrol := nil;
end
inherited;
end
protected
function drawdesigninggrid();
begin
@ -1913,6 +1941,7 @@ type TWinControl = class(tcontrol)
@explan(说明)析构窗口句柄 %%
**}
EndModal();
factivated := false;
if HandleAllocated()then
begin
{FTRACKMOUSEEVENT.hwndtrack := handle;
@ -2465,7 +2494,7 @@ type TWinControl = class(tcontrol)
MainWndProc(h,WM_NCCREATE,0,0);
end
end
public //¶ÔÍâproperty
published //¶ÔÍâproperty
property MinWidth:natural read FMinWidth write SetMinWidth;
property MinHeight:natural read FMinHeigt write SetMinHeight;
//property MaxWidth:integer read FMaxWidth write SetMaxWidth;
@ -2493,6 +2522,7 @@ type TWinControl = class(tcontrol)
property onKillFocus:eventhandler read FonKillFocus write FonKillFocus;
property onSetFocus:eventhandler read FonSetFocus write fonSetFocus;
property oncreated:eventhandler read foncreated write foncreated;
property ActiveControl read getactivecontrol write setactivecontrol;
private //模态相关
property Modaling read FModaling;
@ -2565,4 +2595,33 @@ type TWinControl = class(tcontrol)
if mu.ExecuteCommand("doshortcut",st)="havedoshortcut" then return "havedoshortcut";
end
end
function setactivecontrol(ctl);virtual;
begin
if WsPopUp then
begin
if factivecontrol = ctl then return ;
if ctl is class(TWinControl) then
begin
factivecontrol := ctl;
if factivated then
begin
ctl.SetFocus();
end
end else
begin
factivecontrol := nil;
end
end else
begin
p := parent ;
if p then return p.ActiveControl := ctl;
end
end
function getactivecontrol();
begin
if WsPopUp then return factivecontrol;
factivecontrol := nil;
end
factivecontrol;
end

View File

@ -57,9 +57,8 @@ type tsgtkapi = class(tgtkapis)
global G_GTK_WINDOW_ACTIVATE;
if not hwd then return ;
if not GTK_WIDGET(hwd) then return ;
if f =0 then
if f =0 then //Òþ²Ø
begin
if gtk_widget_is_toplevel(hwd) then
begin
p := GetParent(hwd);
@ -67,7 +66,14 @@ type tsgtkapi = class(tgtkapis)
end
gtk_widget_hide(hwd);
end else
if f=0xc then
if f=0x3 then //×î´ó»¯
begin
if gtk_widget_is_toplevel(hwd) then
begin
gtk_window_maximize(hwd);
end
end else
if f=0xc then //show
begin
if gtk_widget_is_toplevel(hwd) then
begin
@ -80,8 +86,9 @@ type tsgtkapi = class(tgtkapis)
if pp then gtk_window_set_transient_for(hwd,pp);
end
end
gtk_widget_show_all(hwd);
end else
//gtk_widget_show_all(hwd);
gtk_widget_show(hwd);
end else //ÆäËû
begin
if gtk_widget_is_toplevel(hwd) then
begin
@ -3791,7 +3798,8 @@ type tgtkapis = class() //gtk
function gtk_widget_get_window(g:pointer):pointer;cdecl;external 'libgtk-3.so';
procedure gtk_window_get_position(g:pointer;var x:integer;var y:integer);cdecl;external 'libgtk-3.so';
function gtk_image_new_from_file(f:string):pointer;cdecl;external 'libgtk-3.so';
procedure gtk_widget_show_all (window:pointer);cdecl;external 'libgtk-3.so';//'libgtk-x11-2.0.so';
procedure gtk_widget_show_all(window:pointer);cdecl;external 'libgtk-3.so';//'libgtk-x11-2.0.so';
procedure gtk_window_maximize(window:pointer);cdecl;external 'libgtk-3.so';//'libgtk-x11-2.0.so';
procedure gtk_widget_show(window:pointer);cdecl;external 'libgtk-3.so';
procedure gtk_widget_show_now(window:pointer);cdecl;external 'libgtk-3.so';
procedure gtk_widget_hide(window:pointer);cdecl;external 'libgtk-3.so';