1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
| ///////////////////////////////////////////////////////////////////////////
// //
// Copyright (c) 2015 by Charta Software B.V. //
// All rights reserved //
// //
// Version: 1.7.0.83525 //
// Web site: https://pascal.chartasoftware.com/ //
// //
// This code and information are provided "as is" without warranty of //
// any kind. Dissemination of this information or reproduction of //
// this material is strictly forbidden unless prior written permission //
// is obtained from Charta Software B.V.. //
// //
///////////////////////////////////////////////////////////////////////////
unit Application;
interface
uses
Boolean,
Character,
Event,
Exception,
Integer._32.Positive,
Object_.Base,
Text,
UserInterface.Control,
UserInterface.Control.Navigation,
UserInterface.Control.Panel.Paged,
UserInterface.DragAndDrop.Manager,
UserInterface.Keyboard.Event,
UserInterface.Keyboard.HotKey.Manager,
UserInterface.Keyboard.Modifiers,
UserInterface.Mouse.Event,
UserInterface.Object_.Action.Factory,
Value,
Value.Path,
Windows.Api.Messages,
Windows.ClipBoard,
Windows.Control.Window,
Windows.Event.Queue,
Windows.MouseManager;
type
TTargetedEvent = class(TObject)
public
Target: TControl;
Event: TEvent;
destructor Destroy(); override;
end;
TApplication = class(TBaseObject)
protected
FExplorerTarget: TPagedPanel;
FControlFactory: TControlFactory;
ObjectActionFactory: TObjectActionFactory;
ClipBoard: TWindowsClipBoard;
MouseManager: TWindowsMouseManager;
FocusManager: TKeyboardFocusManager;
HotKeyManager: THotKeyManager;
NavigationManager: TControlNavigationManager;
DragAndDropManager: TDragAndDropManager;
ThreadIdentifier: TPositiveInteger32;
EventQueue: TWindowsEventQueue;
SurrogatePairStart: TCharacterCodePoint;
function ConvertMessageToMouseButtonEvent(const Message: TMSG): TMouseButtonEvent;
function ConvertMessageToMouseMoveEvent(const Message: TMSG): TMouseMoveEvent;
function ConvertMessageToMouseWheelEvent(TopLevelControl: TControl; const Message: TMSG): TMouseWheelEvent;
function ConvertMessageToMouseLeaveEvent(TopLevelControl: TControl; const Message: TMSG): TMouseLeaveEvent;
function ConvertMessageToMouseEvent(TopLevelControl: TControl; const Message: TMSG): TMouseEvent;
function ConvertMouseMessage(const Message: TMSG): TTargetedEvent;
function GetCurrentModifierKeys(): TKeyModifiers;
function HandleSurrogatePair(Character: TCharacterCodePoint): TCharacterCodePoint;
function ConvertMessageToKeyboardEvent(const Message: TMSG): TKeyboardEvent;
function PreemptTargetedEvent(TargetedEvent: TTargetedEvent): TBoolean;
function HandleKeyboardEvent(TargetedEvent: TTargetedEvent): TBoolean;
function HandleTargetedEvent(TargetedEvent: TTargetedEvent): TBoolean;
function ConvertKeyboardMessage(const Message: TMSG): TTargetedEvent;
function ConvertMessage(const Message: TMSG): TTargetedEvent;
function HandleMessage(var Message: TMSG): TBoolean;
function CreateWindow(): TWindow; virtual;
function DetermineExplorerTarget(): TPagedPanel;
procedure CloseUserInterface(); virtual;
function EmbellishWithToolbar(Control: TControl; Path: TValuePath): TControl;
public
MainWindow: TWindow; // TODO: make protected again
constructor Create(); override;
procedure Run(); virtual;
procedure OpenControl(Control: TControl; TransferFocus: TBoolean; Target: TPagedPanel = nil);
function OpenControlForValue(Path: TValuePath; TransferFocus: TBoolean; Target: TPagedPanel = nil): TControl;
function Old_OpenControlForValue(Value: TValue; TransferFocus: TBoolean; Target: TPagedPanel = nil): TControl; deprecated 'Use OpenControlForValue() with an entire TValuePath';
procedure ShowError(Message: TText);
procedure ShowException(Exception: EException);
procedure ShowInformation(Message: TText);
function ShowConfirmation(Message: TText): TBoolean;
procedure HandleException(Exception: EException); virtual;
property ControlFactory: TControlFactory read FControlFactory write FControlFactory;
public
class var
Instance: TApplication;
class procedure Main(); virtual; stdcall;
end;
implementation
uses
Character.Set_.Unicode,
Collection.List,
Integer._16,
Log,
Reference.User,
Task.Scheduler,
UserInterface.Control.Query.ExplorerTarget,
UserInterface.Control.Query.Path,
UserInterface.Control.Toolbar,
UserInterface.Keyboard.FocusManager.Default,
UserInterface.Keyboard.Key,
UserInterface.Mouse,
UserInterface.Navigation,
UserInterface.Object_.Action,
UserInterface.Object_.Selection,
Windows.Api.Error,
Windows.Api.Kernel.Thread,
Windows.Api.Type_,
Windows.Api.Type_.Geometry,
Windows.Api.UserInterface,
Windows.Api.VirtualKeyCodes,
Windows.Control,
Windows.Direct2d.Window;
{ TApplication }
constructor TApplication.Create();
begin
inherited Create();
TApplication.Instance := Self;
IsMultiThread := True;
ThreadIdentifier := GetCurrentThreadId();
ClipBoard := TWindowsClipBoard.Create();
HotKeyManager := THotKeyManager.Create();
MouseManager := TWindowsMouseManager.Create();
FocusManager := TDefaultKeyboardFocusManager.Create();
EventQueue := TWindowsEventQueue.Create();
TTaskScheduler.Instance.UserInterfaceEventQueue := EventQueue;
DragAndDropManager := TDragAndDropManager.Create();
DragAndDropManager.MouseManager := MouseManager;
NavigationManager := TControlNavigationManager.Create();
NavigationManager.FocusManager := FocusManager;
NavigationManager.DragAndDropManager := DragAndDropManager;
SurrogatePairStart := TUnicode.NOT_A_CHARACTER_FFFF;
end;
function TApplication.CreateWindow(): TWindow;
begin
Result := TDirect2dWindow.Create();
end;
function TApplication.DetermineExplorerTarget(): TPagedPanel;
var
Source: TControl;
begin
Source := FocusManager.FocusedControl;
if Source = nil then
Source := MainWindow;
Result := Source.FindFirstSibling(TExplorerTargetQuery.Create()) as TPagedPanel;
end;
procedure TApplication.HandleException(Exception: EException);
begin
ShowException(Exception);
TLog.Get([ClassName]).AppendException(Exception);
end;
function TApplication.HandleKeyboardEvent(TargetedEvent: TTargetedEvent): TBoolean;
var
Event: TKeyboardEvent;
KeyDown: TKeyDownEvent;
begin
Event := TargetedEvent.Event as TKeyboardEvent;
Result := (TargetedEvent.Target <> nil) and TargetedEvent.Target.DistributeKeyboardEventUpCompositionHierarchy(Event);
if not Result and (Event is TKeyDownEvent) then
begin
KeyDown := Event as TKeyDownEvent;
if IsNavigationKey(KeyDown.Key) then
Result := NavigationManager.ImmediateNavigateControl(KeyToNavigation(KeyDown.Key, KeyDown.Modifiers));
end;
end;
function TApplication.HandleMessage(var Message: TMSG): TBoolean;
var
TargetedEvent: TTargetedEvent;
begin
TargetedEvent := ConvertMessage(Message);
Result := (TargetedEvent <> nil) and HandleTargetedEvent(TargetedEvent);
// TODO: Here we check whether we receive a '.' on the numeric keypad and translate it to a period, regardless of the keyboard layout and current locale
if (TargetedEvent <> nil) and (TargetedEvent.Event is TKeyStateEvent) and ((TargetedEvent.Event as TKeyStateEvent).Key = TKey.Decimal) then
Message.wParam := VK_OEM_PERIOD;
TargetedEvent.Free();
if not Result then
begin
TranslateMessage(Message);
DispatchMessage(Message);
end;
end;
function TApplication.HandleSurrogatePair(Character: TCharacterCodePoint): TCharacterCodePoint;
begin
if SurrogatePairStart <> TUnicode.NOT_A_CHARACTER_FFFF then
begin
if TUnicode.IsSurrogatePairEnd(Character) then
begin
Result := TUnicode.DecodeSurrogatePair(SurrogatePairStart, Character);
SurrogatePairStart := TUnicode.NOT_A_CHARACTER_FFFF;
end
else
raise EException.Create('Incomplete surrogate pair');
end
else if TUnicode.IsSurrogatePairStart(Character) then
begin
SurrogatePairStart := Character;
Result := TUnicode.NOT_A_CHARACTER_FFFF;
end
else
Result := Character;
end;
function TApplication.HandleTargetedEvent(TargetedEvent: TTargetedEvent): TBoolean;
begin
Result := PreemptTargetedEvent(TargetedEvent);
if not Result then
begin
if TargetedEvent.Event is TMouseEvent then
Result := MouseManager.SendEventToControl(TargetedEvent.Target, TargetedEvent.Event as TMouseEvent)
else if TargetedEvent.Event is TKeyboardEvent then
Result := HandleKeyboardEvent(TargetedEvent);
end;
end;
class procedure TApplication.Main();
begin
{$IF Defined(DEBUG) and not Defined(FPC)}
ReportMemoryLeaksOnShutdown := True;
{$ENDIF}
try
TApplication.Instance := Create();
TApplication.Instance.Run();
TApplication.Instance.Free();
except
on Exception: EException do
TLog.Get(['Startup']).AppendException(Exception);
end;
end;
procedure TApplication.Run();
var
Message: TMSG;
ControlToFocus: TControl;
OK: BOOL;
begin
ControlToFocus := MainWindow.DefaultControlToFocus();
if ControlToFocus <> nil then
ControlToFocus.RequestFocus();
repeat
OK := GetMessage(Message, 0, 0, 0);
if OK.Value = -1 then
EWindows32.RaiseLast()
else if OK then
begin
try
case Message.message of
WM_LBUTTONDOWN,
WM_LBUTTONUP,
WM_MBUTTONDOWN,
WM_MBUTTONUP,
WM_RBUTTONDOWN,
WM_RBUTTONUP,
WM_MOUSEWHEEL,
WM_MOUSEMOVE,
WM_MOUSELEAVE,
WM_KEYDOWN,
WM_KEYUP,
WM_CHAR,
WM_SYSKEYDOWN,
WM_SYSKEYUP,
WM_SYSCHAR:
HandleMessage(Message);
else
DispatchMessage(Message);
end;
except
on Exception: EException do
HandleException(Exception);
end;
end;
until not OK;
CloseUserInterface();
end;
function TApplication.ShowConfirmation(Message: TText): TBoolean;
begin
Result := MessageBox(MainWindow.Handle, Message, 'Confirmation', MB_YESNO) = ID_YES;
end;
procedure TApplication.ShowError(Message: TText);
begin
MessageBox(MainWindow.Handle, Message, 'Error', MB_ICONERROR or MB_OK);
end;
procedure TApplication.ShowException(Exception: EException);
var
Message: TText;
Handle: THandle;
begin
Message := Exception.Message;
if (Self <> nil) and (MainWindow <> nil) then
Handle := MainWindow.Handle
else
Handle := 0;
MessageBox(Handle, Message, 'Exception occurred', MB_ICONERROR or MB_OK);
end;
function TApplication.EmbellishWithToolbar(Control: TControl; Path: TValuePath): TControl;
var
Actions: TList<TObjectAction>;
Selection: TObjectSelection;
Toolbar: TControlToolbar;
ActionBar: TActionBar;
ControlToolbar: TControl;
begin
Selection := TObjectSelection.Create();
Selection.AddReference();
Selection.Objects.Add(Path);
ControlToolBar := Control.CreateToolbar();
Actions := ObjectActionFactory.CreateActionsForObjects(Selection);
Actions.ElementManager := TReferenceUser<TObjectAction>.Create();
if (ControlToolbar <> nil) or (Actions.Count > 0) then
begin
Toolbar := TControlToolbar.Create();
Toolbar.Path := Control.Path;
Toolbar.Caption := Control.Caption;
Toolbar.PanelControl := Control.Embellish();
if ControlToolbar <> nil then
Toolbar.Toolbar.AddControl(ControlToolbar);
if Actions.Count > 0 then
begin
ActionBar := TActionBar.Create();
ActionBar.Add(Actions);
Toolbar.Toolbar.AddControl(ActionBar);
end;
Result := Toolbar;
end
else
Result := Control;
Actions.Free();
Selection.ReleaseReference();
end;
function TApplication.GetCurrentModifierKeys(): TKeyModifiers;
begin
Result := [];
if GetKeyState(VK_SHIFT) < 0 then
Result := Result + [TKeyModifier.Shift];
if GetKeyState(VK_CONTROL) < 0 then
Result := Result + [TKeyModifier.Control];
if GetKeyState(VK_MENU) < 0 then
Result := Result + [TKeyModifier.Alt];
end;
procedure TApplication.CloseUserInterface();
begin
MainWindow.Free();
MainWindow := nil;
ControlFactory.Free();
ClipBoard.Free();
MouseManager.Free();
FocusManager.Free();
HotKeyManager.Free();
NavigationManager.Free();
DragAndDropManager.Free();
EventQueue.Free();
end;
function TApplication.ConvertKeyboardMessage(const Message: TMSG): TTargetedEvent;
var
KeyboardEvent: TKeyboardEvent;
FocusManager: TKeyboardFocusManager;
begin
KeyboardEvent := ConvertMessageToKeyboardEvent(Message);
if KeyboardEvent <> nil then
begin
if MainWindow.ContextMenuControl.IsVisible then
FocusManager := MainWindow.ContextMenuControl.GetFocusManager()
else
FocusManager := MainWindow.GetFocusManager();
Result := TTargetedEvent.Create();
Result.Target := FocusManager.FocusedControl;
Result.Event := KeyboardEvent;
end
else
Result := nil;
end;
function TApplication.ConvertMessage(const Message: TMSG): TTargetedEvent;
begin
case Message.message of
WM_LBUTTONDOWN, WM_LBUTTONUP, WM_MBUTTONDOWN, WM_MBUTTONUP, WM_RBUTTONDOWN, WM_RBUTTONUP, WM_MOUSEWHEEL, WM_MOUSEMOVE, WM_MOUSELEAVE:
Result := ConvertMouseMessage(Message);
WM_KEYDOWN, WM_KEYUP, WM_CHAR, WM_SYSKEYDOWN, WM_SYSKEYUP, WM_SYSCHAR:
Result := ConvertKeyboardMessage(Message);
else
raise EException.Create('Unknown message');
end;
end;
function TApplication.ConvertMessageToKeyboardEvent(const Message: TMSG): TKeyboardEvent;
var
Modifiers: TKeyModifiers;
Character: TCharacterCodePoint;
begin
Modifiers := GetCurrentModifierKeys();
case Message.message of
WM_KEYDOWN, WM_SYSKEYDOWN:
Result := TKeyDownEvent.Create(FocusManager.Keyboard, Modifiers, TVirtualKey.ToKey(Message.wParam));
WM_KEYUP, WM_SYSKEYUP:
Result := TKeyUpEvent.Create(FocusManager.Keyboard, Modifiers, TVirtualKey.ToKey(Message.wParam));
WM_CHAR:
begin
Character := HandleSurrogatePair(Message.wParam);
if Character <> TUnicode.NOT_A_CHARACTER_FFFF then
Result := TKeyPressEvent.Create(FocusManager.Keyboard, Modifiers, Character)
else
Result := nil;
end;
WM_SYSCHAR:
Result := TKeyPressEvent.Create(FocusManager.Keyboard, Modifiers, Message.wParam);
else
raise EException.Create('Unknown keyboard message');
end;
end;
function TApplication.ConvertMessageToMouseButtonEvent(const Message: TMSG): TMouseButtonEvent;
var
Mouse: TMouse;
ButtonState: TMouseButtonState;
begin
Mouse := MouseManager.Mouse;
case Message.message of
WM_LBUTTONDOWN, WM_MBUTTONDOWN, WM_RBUTTONDOWN:
Result := TMouseButtonDownEvent.Create(Mouse);
WM_LBUTTONUP, WM_MBUTTONUP, WM_RBUTTONUP:
Result := TMouseButtonUpEvent.Create(Mouse);
else
raise EException.Create('Unknown mouse button message');
end;
case Message.message of
WM_LBUTTONDOWN, WM_LBUTTONUP:
Result.Button := Mouse.Left;
WM_MBUTTONDOWN, WM_MBUTTONUP:
Result.Button := Mouse.Middle;
WM_RBUTTONDOWN, WM_RBUTTONUP:
Result.Button := Mouse.Right;
else
raise EException.Create('Unknown mouse button message');
end;
case Message.message of
WM_LBUTTONDOWN, WM_MBUTTONDOWN, WM_RBUTTONDOWN:
ButtonState := Result.Button.Down;
WM_LBUTTONUP, WM_MBUTTONUP, WM_RBUTTONUP:
ButtonState := Result.Button.Up;
else
raise EException.Create('Unknown mouse button state');
end;
Result.Position := GetPointFromLParam(Message.lParam);
Result.KeyModifiers := GetCurrentModifierKeys();
Result.Count := ButtonState.HandleRepetition(Result.Position, Message.Time);
end;
function TApplication.ConvertMessageToMouseEvent(TopLevelControl: TControl; const Message: TMSG): TMouseEvent;
begin
case Message.message of
WM_LBUTTONDOWN, WM_MBUTTONDOWN, WM_RBUTTONDOWN, WM_LBUTTONUP, WM_MBUTTONUP, WM_RBUTTONUP:
Result := ConvertMessageToMouseButtonEvent(Message);
WM_MOUSEMOVE:
Result := ConvertMessageToMouseMoveEvent(Message);
WM_MOUSEWHEEL:
Result := ConvertMessageToMouseWheelEvent(TopLevelControl, Message);
WM_MOUSELEAVE:
Result := ConvertMessageToMouseLeaveEvent(TopLevelControl, Message);
else
raise EException.Create('Unknown mouse message');
end;
end;
function TApplication.ConvertMessageToMouseLeaveEvent(TopLevelControl: TControl; const Message: TMSG): TMouseLeaveEvent;
begin
Result := TMouseLeaveEvent.Create(MouseManager.Mouse);
Result.Position := TopLevelControl.ScreenToRelative(MouseManager.GetCursorPosition());
end;
function TApplication.ConvertMessageToMouseMoveEvent(const Message: TMSG): TMouseMoveEvent;
begin
Result := TMouseMoveEvent.Create(MouseManager.Mouse);
Result.Position := GetPointFromLParam(Message.lParam);
Result.KeyModifiers := GetCurrentModifierKeys();
end;
function TApplication.ConvertMessageToMouseWheelEvent(TopLevelControl: TControl; const Message: TMSG): TMouseWheelEvent;
begin
Result := TMouseWheelEvent.Create(MouseManager.Mouse);
Result.Delta := TInteger16((Message.wParam and $FFFF0000) shr 16);
Result.Position := TopLevelControl.ScreenToRelative(GetPointFromLParam(Message.lParam));
Result.KeyModifiers := GetCurrentModifierKeys();
end;
function TApplication.ConvertMouseMessage(const Message: TMSG): TTargetedEvent;
var
Event: TMouseEvent;
TopLevelControl: TControl;
Point: TPoint;
begin
if Message.message = WM_MOUSEWHEEL then
begin
Point := GetPointFromLParam(Message.lParam);
TopLevelControl := FindControlWithHandle(WindowFromPoint(Point));
end
else
TopLevelControl := FindControlWithHandle(Message.hwnd);
if TopLevelControl <> nil then
begin
Event := ConvertMessageToMouseEvent(TopLevelControl, Message);
Event.UpdateMouseState();
Result := TTargetedEvent.Create();
Result.Target := TopLevelControl;
Result.Event := Event;
end
else
Result := nil;
end;
procedure TApplication.OpenControl(Control: TControl; TransferFocus: TBoolean; Target: TPagedPanel = nil);
begin
if Target = nil then
Target := DetermineExplorerTarget();
if Target <> nil then
begin
Target.AddPage(Control);
if TransferFocus then
Control.Enter();
end;
end;
function TApplication.Old_OpenControlForValue(Value: TValue; TransferFocus: TBoolean; Target: TPagedPanel = nil): TControl;
var
Path: TValuePath;
begin
Path := TValuePath.Create([Value]);
Path.AddReference();
try
Result := OpenControlForValue(Path, TransferFocus, Target);
finally
Path.ReleaseReference();
end;
end;
function TApplication.OpenControlForValue(Path: TValuePath; TransferFocus: TBoolean; Target: TPagedPanel): TControl;
var
Source: TControl;
begin
Path.AddReference();
try
if Path.Length > 0 then
begin
Source := FocusManager.FocusedControl;
if Source = nil then
Source := MainWindow;
if Source <> nil then
Result := Source.FindFirstSibling(TPathQuery.Create(Path.ExtractLastObject()))
else
Result := nil;
if Result = nil then
begin
Result := ControlFactory.CreateControl(ControlFactory, TControlPurpose.Standalone, Path);
if Result <> nil then
begin
// TODO: We should never assign Result.Path here and instead rely on the control factory to assign a proper path
if Result.Path = nil then
Result.Path := Path;
Result := EmbellishWithToolbar(Result, Path);
OpenControl(Result, TransferFocus, Target);
end;
end
else if TransferFocus then
Result.Enter();
end
else
Result := nil;
finally
Path.ReleaseReference();
end;
end;
procedure TApplication.ShowInformation(Message: TText);
begin
MessageBox(MainWindow.Handle, Message, 'Information', MB_ICONINFORMATION or MB_OK);
end;
function TApplication.PreemptTargetedEvent(TargetedEvent: TTargetedEvent): TBoolean;
begin
if DragAndDropManager.IsActive() then
Result := DragAndDropManager.HandleEvent(TargetedEvent.Target, TargetedEvent.Event)
else if NavigationManager.IsActive then
Result := NavigationManager.HandleEvent(TargetedEvent.Event)
else
Result :=
HotKeyManager.HandleEvent(TargetedEvent.Event)
or DragAndDropManager.HandleEvent(TargetedEvent.Target, TargetedEvent.Event)
or NavigationManager.HandleEvent(TargetedEvent.Event);
end;
{ TTargetedEvent }
destructor TTargetedEvent.Destroy();
begin
Event.Free();
inherited Destroy();
end;
end.
|