Changeset 13 for os/trunk/System


Ignore:
Timestamp:
Feb 29, 2016, 3:09:13 PM (9 years ago)
Author:
chronos
Message:
  • Modified: Allow receive mouse move mesages to focused form even if mouse position is outside of form area.
  • Fixed: Pass key press messages only to focused form and focused TControl like TEdit.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • os/trunk/System/LDOS.Kernel.pas

    r8 r13  
    5555  TScreen = class(TComponent)
    5656  private
     57    function GetFocusedForm: TForm;
     58    procedure SetFocusedForm(const Value: TForm);
    5759  public
    5860    Kernel: TKernel;
     
    6365    procedure HandleResize;
    6466    procedure Paint;
    65     procedure FocusForm(Form: TForm);
     67    property FocusedForm: TForm read GetFocusedForm write SetFocusedForm;
    6668    constructor Create; override;
    6769    destructor Destroy; override;
     
    7880  TMouse = class
    7981    Kernel: TKernel;
     82    MovedForm: TForm;
    8083    procedure HandleMove(Position: TPoint);
    8184    procedure HandleDown(Position: TPoint);
     
    233236end;
    234237
    235 procedure TScreen.FocusForm(Form: TForm);
    236 var
    237   I: Integer;
    238   FormIndex: Integer;
    239 begin
    240   FormIndex := Forms.IndexOf(Form);
    241   for I := 0 to Forms.Count - 1 do
    242     Forms[I].Focused := I = FormIndex;
    243 
    244   Forms.Move(FormIndex, Forms.Count - 1);
    245   Paint;
     238function TScreen.GetFocusedForm: TForm;
     239begin
     240  if Forms.Count > 0 then
     241   Result := Forms[Forms.Count - 1]
     242   else Result := nil;
    246243end;
    247244
     
    272269end;
    273270
     271procedure TScreen.SetFocusedForm(const Value: TForm);
     272var
     273  I: Integer;
     274  FormIndex: Integer;
     275begin
     276  FormIndex := Forms.IndexOf(Value);
     277  for I := 0 to Forms.Count - 1 do
     278    Forms[I].Focused := I = FormIndex;
     279
     280  Forms.Move(FormIndex, Forms.Count - 1);
     281  Paint;
     282end;
     283
    274284{ TDriver }
    275285
     
    313323  try
    314324    for Form in Kernel.Screen.Forms do
     325    if Form.Focused then
    315326    if Form.HandleMessage(NewMessage) then begin
    316327      Break;
     
    356367begin
    357368  NewMessage := TMessageMouseDown.Create;
     369  NewMessage.Position := Position;
     370  try
     371    for Form in Kernel.Screen.Forms do
     372    if Form.Bounds.Contains(Position) then begin
     373      MovedForm := Form;
     374      if Form.HandleMessage(NewMessage) then begin
     375        Break;
     376      end;
     377    end;
     378  finally
     379    NewMessage.Destroy;
     380  end;
     381end;
     382
     383procedure TMouse.HandleMove(Position: TPoint);
     384var
     385  Form: TForm;
     386  NewMessage: TMessageMouseMove;
     387begin
     388  NewMessage := TMessageMouseMove.Create;
    358389  NewMessage.Position := Position;
    359390  try
     
    364395      end;
    365396    end;
    366   finally
    367     NewMessage.Destroy;
    368   end;
    369 end;
    370 
    371 procedure TMouse.HandleMove(Position: TPoint);
    372 var
    373   Form: TForm;
    374   NewMessage: TMessageMouseMove;
    375 begin
    376   NewMessage := TMessageMouseMove.Create;
     397    if Assigned(Kernel.Screen.FocusedForm) then
     398      Kernel.Screen.FocusedForm.HandleMessage(NewMessage);
     399  finally
     400    NewMessage.Destroy;
     401  end;
     402end;
     403
     404procedure TMouse.HandleUp(Position: TPoint);
     405var
     406  Form: TForm;
     407  NewMessage: TMessageMouseUp;
     408begin
     409  NewMessage := TMessageMouseUp.Create;
    377410  NewMessage.Position := Position;
    378411  try
     
    383416      end;
    384417    end;
    385   finally
    386     NewMessage.Destroy;
    387   end;
    388 end;
    389 
    390 procedure TMouse.HandleUp(Position: TPoint);
    391 var
    392   Form: TForm;
    393   NewMessage: TMessageMouseUp;
    394 begin
    395   NewMessage := TMessageMouseUp.Create;
    396   NewMessage.Position := Position;
    397   try
    398     for Form in Kernel.Screen.Forms do
    399     if Form.Bounds.Contains(Position) then begin
    400       if Form.HandleMessage(NewMessage) then begin
    401         Break;
    402       end;
    403     end;
     418    if Assigned(Kernel.Screen.FocusedForm) then
     419      Kernel.Screen.FocusedForm.HandleMessage(NewMessage);
    404420  finally
    405421    NewMessage.Destroy;
Note: See TracChangeset for help on using the changeset viewer.