summaryrefslogtreecommitdiff
path: root/gfx
diff options
context:
space:
mode:
authorsekelsenmat <sekelsenmat@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2007-07-13 08:33:47 +0000
committersekelsenmat <sekelsenmat@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2007-07-13 08:33:47 +0000
commite059fdd639225427c788c2082ba19a321f6b1c46 (patch)
tree873ddcf9d6c29eed8fa4651801af6ce697b6b7fd /gfx
parent28b15796b4e5550fbe1837b4242bcadc50bfbcbd (diff)
downloadfpGUI-e059fdd639225427c788c2082ba19a321f6b1c46.tar.xz
Disallowed passing events to parent widget and implemented focus policy.
Diffstat (limited to 'gfx')
-rw-r--r--gfx/gdi/gfx_gdi.pas55
-rw-r--r--gfx/gfxbase.pas12
2 files changed, 42 insertions, 25 deletions
diff --git a/gfx/gdi/gfx_gdi.pas b/gfx/gdi/gfx_gdi.pas
index 3a567547..293fd50a 100644
--- a/gfx/gdi/gfx_gdi.pas
+++ b/gfx/gdi/gfx_gdi.pas
@@ -1510,12 +1510,15 @@ procedure TGDIWindow.EvKeyPressed(AKey: Word);
var
vEvent: TFEvent;
begin
- if Assigned(OnKeyPressed) then OnKeyPressed(Self, AKey, GetKeyboardShiftState)
- else if Assigned(Parent) then
+ if GetRootWindow().FocusedWindow = Self then
+ begin
+ if Assigned(OnKeyPressed) then OnKeyPressed(Self, AKey, GetKeyboardShiftState);
+ end
+ else
begin
vEvent.EventType := etKeyPressed;
vEvent.Key := AKey;
- Parent.ProcessEvent(vEvent);
+ GetRootWindow().FocusedWindow.ProcessEvent(vEvent);
end;
end;
@@ -1523,12 +1526,15 @@ procedure TGDIWindow.EvKeyReleased(AKey: Word);
var
vEvent: TFEvent;
begin
- if Assigned(OnKeyReleased) then OnKeyReleased(Self, AKey, GetKeyboardShiftState)
- else if Assigned(Parent) then
+ if GetRootWindow().FocusedWindow = Self then
+ begin
+ if Assigned(OnKeyReleased) then OnKeyReleased(Self, AKey, GetKeyboardShiftState);
+ end
+ else
begin
vEvent.EventType := etKeyReleased;
vEvent.Key := AKey;
- Parent.ProcessEvent(vEvent);
+ GetRootWindow().FocusedWindow.ProcessEvent(vEvent);
end;
end;
@@ -1536,12 +1542,15 @@ procedure TGDIWindow.EvKeyChar(AKeyChar: Char);
var
vEvent: TFEvent;
begin
- if Assigned(OnKeyChar) then OnKeyChar(Self, AKeyChar)
- else if Assigned(Parent) then
+ if GetRootWindow().FocusedWindow = Self then
+ begin
+ if Assigned(OnKeyChar) then OnKeyChar(Self, AKeyChar);
+ end
+ else
begin
vEvent.EventType := etKeyChar;
vEvent.KeyChar := AKeyChar;
- Parent.ProcessEvent(vEvent);
+ GetRootWindow().FocusedWindow.ProcessEvent(vEvent);
end;
end;
@@ -1576,15 +1585,19 @@ procedure TGDIWindow.EvMousePressed(AButton: TMouseButton;
var
vEvent: TFEvent;
begin
+ { Defines focus }
+ if FFocusable then GetRootWindow().FocusedWindow := Self;
+
+ { Processes the event }
if Assigned(OnMousePressed) then
- OnMousePressed(Self, AButton, GetKeyboardShiftState, AMousePos)
- else if Assigned(Parent) then
+ OnMousePressed(Self, AButton, GetKeyboardShiftState, AMousePos);
+{ else if Assigned(Parent) then
begin
vEvent.EventType := etMousePressed;
vEvent.MousePos := AMousePos;
vEvent.MouseButton := AButton;
Parent.ProcessEvent(vEvent);
- end;
+ end; }
end;
procedure TGDIWindow.EvMouseReleased(AButton: TMouseButton;
@@ -1593,14 +1606,14 @@ var
vEvent: TFEvent;
begin
if Assigned(OnMouseReleased) then
- OnMouseReleased(Self, AButton, GetKeyboardShiftState, AMousePos)
- else if Assigned(Parent) then
+ OnMouseReleased(Self, AButton, GetKeyboardShiftState, AMousePos);
+{ else if Assigned(Parent) then
begin
vEvent.EventType := etMouseReleased;
vEvent.MousePos := AMousePos;
vEvent.MouseButton := AButton;
Parent.ProcessEvent(vEvent);
- end;
+ end; }
end;
procedure TGDIWindow.EvMouseMove(const AMousePos: TPoint);
@@ -1608,13 +1621,13 @@ var
vEvent: TFEvent;
begin
if Assigned(OnMouseMove) then
- OnMouseMove(Self, GetKeyboardShiftState, AMousePos)
- else if Assigned(Parent) then
+ OnMouseMove(Self, GetKeyboardShiftState, AMousePos);
+{ else if Assigned(Parent) then
begin
vEvent.EventType := etMouseMove;
vEvent.MousePos := AMousePos;
Parent.ProcessEvent(vEvent);
- end;
+ end; }
end;
procedure TGDIWindow.EvMouseWheel(AWheelDelta: Single; const AMousePos: TPoint);
@@ -1622,14 +1635,14 @@ var
vEvent: TFEvent;
begin
if Assigned(OnMouseWheel) then
- OnMouseWheel(Self, GetKeyboardShiftState, AWheelDelta, AMousePos)
- else if Assigned(Parent) then
+ OnMouseWheel(Self, GetKeyboardShiftState, AWheelDelta, AMousePos);
+{ else if Assigned(Parent) then
begin
vEvent.EventType := etMouseMove;
vEvent.WheelDelta := AWheelDelta;
vEvent.MousePos := AMousePos;
Parent.ProcessEvent(vEvent);
- end;
+ end;}
end;
{ Because the painting code is executed on the middle of the processing
diff --git a/gfx/gfxbase.pas b/gfx/gfxbase.pas
index efbee2db..30abebae 100644
--- a/gfx/gfxbase.pas
+++ b/gfx/gfxbase.pas
@@ -557,13 +557,15 @@ type
{ Event processing methods }
procedure ProcessEvent(AEvent: TFEvent);
{ Methods of the child windows list }
- function FindTopParentWindow: TFCustomWindow;
+ function GetRootWindow: TFCustomWindow;
{ Properties }
property WindowOptions: TFWindowOptions read FWindowOptions write SetWindowOptions;
property Canvas: TFCustomCanvas read FCanvas;
property Handle: PtrUInt read GetHandle;
+ { Properties of the child windows list }
property ChildWindows: TList read FChildWindows;
+ property FocusedWindow: TFCustomWindow read FFocusedWindow write FFocusedWindow;
{ Window state }
property ClientWidth: Integer read FClientWidth write SetClientWidth;
property ClientHeight: Integer read FClientHeight write SetClientHeight;
@@ -1065,7 +1067,9 @@ begin
FParent := AParent;
FChildWindows := TList.Create;
-
+
+ FFocusedWindow := Self;
+
if AParent <> nil then AParent.ChildWindows.Add(Self);
end;
@@ -1131,9 +1135,9 @@ begin
end;
{ Finds the top window througth recursion }
-function TFCustomWindow.FindTopParentWindow: TFCustomWindow;
+function TFCustomWindow.GetRootWindow: TFCustomWindow;
begin
- if Assigned(Parent) then Result := Parent.FindTopParentWindow
+ if Assigned(Parent) then Result := Parent.GetRootWindow
else Result := Self;
end;