View Issue Details

IDProjectCategoryView StatusLast Update
0036221LazarusWidgetsetpublic2019-11-03 22:26
ReporterC Western Assigned ToDmitry Boyarintsev  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Platformx86_64OSMACOSX 
Product Version2.0.5 (SVN) 
Summary0036221: Mouse Wheel events going to wrong window
DescriptionIn the attached project, the OnMouseWheel event is triggered on gtk2, but not under Cocoa. Note that if the OnMouseWheel of the panel or form is connected, these are triggered under Cocoa.
Steps To ReproduceIn attached project, do mouse wheel up down on either of the two edit controls. The edit text should change.
TagsNo tags attached.
Fixed in Revision62145 62156
LazTarget-
WidgetsetCocoa
Attached Files

Activities

C Western

2019-10-27 13:08

reporter  

unit1.pas (689 bytes)   
unit Unit1;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, Spin, StdCtrls,
  ExtCtrls, Types;

type

  { TForm1 }

  TForm1 = class(TForm)
    Edit1: TEdit;
    Edit2: TEdit;
    Panel1: TPanel;
    procedure Edit1MouseWheel(Sender: TObject; Shift: TShiftState;
      WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
  private

  public

  end;

var
  Form1: TForm1;

implementation

{$R *.lfm}

{ TForm1 }

procedure TForm1.Edit1MouseWheel(Sender: TObject; Shift: TShiftState;
  WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
begin
  Edit1.Text := (Sender as TComponent).Name + IntToStr(WheelDelta);
end;

end.

unit1.pas (689 bytes)   
unit1.lfm (686 bytes)   
object Form1: TForm1
  Left = 394
  Height = 240
  Top = 881
  Width = 320
  Caption = 'Form1'
  ClientHeight = 240
  ClientWidth = 320
  LCLVersion = '2.1.0.0'
  object Edit1: TEdit
    Left = 16
    Height = 22
    Top = 64
    Width = 80
    OnMouseWheel = Edit1MouseWheel
    TabOrder = 0
    Text = 'Edit1'
  end
  object Panel1: TPanel
    Left = 0
    Height = 50
    Top = 0
    Width = 320
    Align = alTop
    Caption = 'Panel1'
    ClientHeight = 50
    ClientWidth = 320
    TabOrder = 1
    object Edit2: TEdit
      Left = 16
      Height = 22
      Top = 16
      Width = 80
      OnMouseWheel = Edit1MouseWheel
      TabOrder = 0
      Text = 'Edit2'
    end
  end
end
unit1.lfm (686 bytes)   
wheeltest.lpr (364 bytes)   
program wheeltest;

{$mode objfpc}{$H+}

uses
  {$IFDEF UNIX}
  cthreads,
  {$ENDIF}
  Interfaces, // this includes the LCL widgetset
  Forms, Unit1
  { you can add units after this };

{$R *.res}

begin
  RequireDerivedFormResource := True;
  Application.Scaled := True;
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.Run;
end.

wheeltest.lpr (364 bytes)   

Dmitry Boyarintsev

2019-10-29 04:09

developer   ~0118902

please test and close if ok

C Western

2019-10-29 23:34

reporter   ~0118920

The event now looks to be going to the right window - thanks, However, the following code in CocoaWSCommon may need adjustment:

  // Some info on event.deltaY can be found here:
  // https://developer.apple.com/library/mac/releasenotes/AppKit/RN-AppKitOlderNotes/
  // It says that deltaY=1 means 1 line, and in the LCL 1 line is 120
  if event.deltaY <> 0 then
  begin
    Msg.Msg := LM_MOUSEWHEEL;
    Msg.WheelDelta := round(event.deltaY * 120);
  end

On Cocoa a single mouse wheel notch click yields 0.1 (on my setup at least) for event.deltaY, giving a Msg.WheelDelta of 12, whereas other widget sets yield 40. (It doesn't seem to be affected by the system scroll speed setting.)

Dmitry Boyarintsev

2019-11-02 21:43

developer   ~0118992

added in 62156

C Western

2019-11-03 22:26

reporter   ~0119025

I suspect Mouse.WheelScrollLines should return 10, at least on my system, but some testing on other systems would be desirable.

Issue History

Date Modified Username Field Change
2019-10-27 13:08 C Western New Issue
2019-10-27 13:08 C Western File Added: unit1.pas
2019-10-27 13:08 C Western File Added: unit1.lfm
2019-10-27 13:08 C Western File Added: wheeltest.lpr
2019-10-29 04:09 Dmitry Boyarintsev Assigned To => Dmitry Boyarintsev
2019-10-29 04:09 Dmitry Boyarintsev Status new => resolved
2019-10-29 04:09 Dmitry Boyarintsev Resolution open => fixed
2019-10-29 04:09 Dmitry Boyarintsev Fixed in Revision => 62145
2019-10-29 04:09 Dmitry Boyarintsev LazTarget => -
2019-10-29 04:09 Dmitry Boyarintsev Widgetset Cocoa => Cocoa
2019-10-29 04:09 Dmitry Boyarintsev Note Added: 0118902
2019-10-29 23:34 C Western Note Added: 0118920
2019-11-02 21:43 Dmitry Boyarintsev Fixed in Revision 62145 => 62145 62156
2019-11-02 21:43 Dmitry Boyarintsev Widgetset Cocoa => Cocoa
2019-11-02 21:43 Dmitry Boyarintsev Note Added: 0118992
2019-11-03 22:26 C Western Note Added: 0119025