View Issue Details

IDProjectCategoryView StatusLast Update
0034485LazarusLCLpublic2020-08-11 19:04
ReporterChris Rorden Assigned To 
PrioritynormalSeverityminorReproducibilityalways
Status newResolutionopen 
PlatformSystem76 Oryx ProOSPopOS (Ubuntu) 
Product Version2.1 (SVN) 
Summary0034485: GTK2 does not have getKeyshiftstate() for FormDropFiles
DescriptionDropping files from the explorer (nautilus, finder, etc) onto a program is a useful way to load files. It is often nice to detect if any keys are pressed (e.g. shift state) to provide special options. With Windows and Cocoa widgets, I can use getKeyshiftstate at the time an object is dropped. This does not work reliably for me using GTK2 and Ubuntu 18.04.
Steps To Reproduceprocedure TForm1.FormDropFiles(Sender: TObject; const FileNames: array of String);
//uses LCLIntf, LCLType;
var
  K: Smallint;
  ss: TShiftState;
begin
  Label1.Caption := 'FileName: '+ Filenames[0];
  ss := getKeyshiftstate;
  if (ssMeta in ss) or (ssCtrl in ss) or (ssShift in ss) then
     Label2.Caption := 'getKeyshiftstate detected'
  else
     Label2.Caption := 'getKeyshiftstate NOT detected';
  if (GetKeyState(VK_SHIFT) And $80) <> 0 then
     Label3.Caption := 'GetKeyState detected'
  else
     Label3.Caption := 'GetKeyState NOT detected';
  K:= GetKeyState(VK_SHIFT);
  Label4.Caption := 'GetKeyState = '+inttostr(K);
end;
Additional InformationMight be related to issue 33828
TagsNo tags attached.
Fixed in Revision
LazTarget
WidgetsetGTK 2
Attached Files

Relationships

related to 0033828 new Lazarus GetKeyState broken for VK_NUMLOCK, _SCROLL, _CAPITAL when changes occur without window focus 
related to 0037383 new Patches gtk2: Simpler storage of pressed keys: FPList->array 

Activities

Chris Rorden

2018-10-30 18:04

reporter  

dragdrop.zip (3,161 bytes)

CudaText man

2018-10-31 09:23

reporter   ~0111703

if (GetKeyState(VK_SHIFT) And $80) <> 0 then
--> usually we write
  if GetKeyState(VK_SHIFT)<0 then

Juha Manninen

2020-07-17 23:55

developer   ~0124135

Somebody should study this:
function TGtk2WidgetSet.GetKeyState(nVirtKey: Integer): Smallint;

The respective LCL-QT5 method works.
function TQtWidgetSet.GetKeyState(nVirtKey: Integer): Smallint;

CudaText man

2020-07-18 00:45

reporter   ~0124137

Reason:
  {$IFDEF Use_KeyStateList}
  gtk_key_snooper_install(@GTKKeySnooper, FKeyStateList_);
  {$ELSE}

this handler is NOT called if shift/ctrl is pressed in file-manager. it's called when key is pressed in Laz app.
so FKeyStateList_ - empty.

Cyrax

2020-07-18 19:49

reporter   ~0124151

Perhaps adapting this code to Free Pascal and combining it in to Lazarus GTK2 widgeset would help in this matter : https://github.com/kupferlauncher/keybinder

CudaText man_

2020-08-11 19:04

reporter   ~0124776

Is this a code to install global OS key hook? not ok for Laz apps.

Issue History

Date Modified Username Field Change
2018-10-30 18:04 Chris Rorden New Issue
2018-10-30 18:04 Chris Rorden File Added: dragdrop.zip
2018-10-30 18:18 Juha Manninen Relationship added related to 0033828
2018-10-31 09:23 CudaText man Note Added: 0111703
2020-07-17 23:55 Juha Manninen Note Added: 0124135
2020-07-18 00:45 CudaText man Note Added: 0124137
2020-07-18 16:53 Juha Manninen Relationship added related to 0037383
2020-07-18 19:49 Cyrax Note Added: 0124151
2020-08-11 19:04 CudaText man_ Note Added: 0124776