Recent

Author Topic: Ability to use the Win key to assign a specific IDE function  (Read 2678 times)

flowCRANE

  • Hero Member
  • *****
  • Posts: 885
Re: Ability to use the Win key to assign a specific IDE function
« Reply #30 on: October 18, 2024, 02:54:12 pm »
@n7800: I tried applying your commits again and everything is fine, the Win key shortcuts work fabulously! As I wrote above, I used the Win+Alt+Left/Right shortcuts for the Go to next/prior editor option and the Win+Alt+Up/Down shortcuts for the Go to next/prior window option — everything works correctly.

There is one small problem with the Grab key window, after applying the changes. Regardless of whether the Allow use of Meta key checkbox is checked or not, pressing Esc closes the Grab key window and reopens it — only pressing Esc a second time closes the window and cancels grabbing the shortcut. Something is getting stuck in a loop, so canceling a second time opens the capture window — this should be easy to fix.

This window behaves similarly when you capture a shortcut with the Win key — the first press of the shortcut is captured and the window closes, but it immediately appears a second time and I have to press the shortcut again.

Do you have these problems or did I do something wrong again?  8)
Lazarus 3.6 with FPC 3.2.2, Windows 10 — all 64-bit

Working solo on a retro-style action/adventure game (pixel art), programming the engine from scratch, using Free Pascal and SDL.

n7800

  • Full Member
  • ***
  • Posts: 173
Re: Ability to use the Win key to assign a specific IDE function
« Reply #31 on: October 18, 2024, 09:17:11 pm »
And that is why I personally think the Win-Key should not be an (advertised) feature in the Keymap.
...
But I wouldn't advertise adding it, because of the cost of maintenance.

I hear again that I'm supposedly "advertising" something... How can the phrase "OS dependent, no guarantee of functionality" be considered "advertising"? How can an additional click of the flag (with each editing of the shortcut!) be considered a call to action?

I repeat, MR adds a warning. And prohibits the grab window from accepting combinations with invalid modifiers. And fixes a bug when the [Meta] checkbox was not visible, but it was checked.

And because of it couldn't be guaranteed as future-safe. It may just disappear.

(Yes,  I did read that it already exists... So, for those using it, lets hope it doesn't disappear)

This is the Windows API, and I doubt that this will change. There are enough programs that use such combinations (for example, programs for custom virtual desktops, creating screenshots/screencast and other).

In my program for keyboard shortcuts (written in Lazarus), I use many combinations with this key - that is, the OS allows you to register even global key combinations with it (which work even when the application is minimized to the tray).

n7800

  • Full Member
  • ***
  • Posts: 173
Re: Ability to use the Win key to assign a specific IDE function
« Reply #32 on: October 18, 2024, 09:37:55 pm »
However, both of these shortcuts do nothing on my computer (Win10, two monitors) ...

It's strange, I use them all the time (Win+Left/Right). Just curious, have you checked, for example, on the Explorer window? The grab window ignores these combinations, since it has no borders that allow resizing, but other windows should work.

... so I wrongly assumed the system was not using them at all (so they are free).

I will probably add to the checkbox Hint that a good way to make sure is to press the combination in the grab window. If it catches the combination, then it should work in other IDE windows.

To solve this and inform the user about which keyboard shortcuts are reserved, it would be good to check their list in Microsoft's documentation and provide access to this information in the IDE interface (maybe a button or link that opens documentation with a list of shortcuts and information about what the system uses them for), so that the user can familiarize themselves with this information. You can also add such link in the Grab key window.

You would have to think about how to do it properly, i.e. on the one hand, it would be possible to assign shortcuts with the Meta key, and on the other hand, so that the user has access to information about which shortcuts are reserved by the OS (i.e. so that he does not have a grudge against the IDE developers that something does not work and does not consider it a bug).

Informing about such a list is the task of the OS, and not all applications on the computer. In addition, even Microsoft does not always document everything it does. What can we say about other applications that can also intercept some combinations? I will not even say that Lazarus is cross-platform ))

If needed, adding support for Meta key shortcuts does not need to be implemented in the Lazarus sources — it can be in a separate package, installed optionally (like AnchorDockingDsgn for docked IDE, or metadarkstyle for the IDE's dark theme on Windows).

The last thing I want is to have separate packages for each checkbox... Also, for the package to communicate with the IDE, we need to add the appropriate interfaces. I don't know, but I think this will require even more code. Let me remind that we are talking about only one one checkbox (which is shown by default on MacOS)...

n7800

  • Full Member
  • ***
  • Posts: 173
Re: Ability to use the Win key to assign a specific IDE function
« Reply #33 on: October 18, 2024, 11:09:32 pm »
There is one small problem with the Grab key window, after applying the changes. Regardless of whether the Allow use of Meta key checkbox is checked or not, pressing Esc closes the Grab key window and reopens it — only pressing Esc a second time closes the window and cancels grabbing the shortcut. Something is getting stuck in a loop, so canceling a second time opens the capture window — this should be easy to fix.

This window behaves similarly when you capture a shortcut with the Win key — the first press of the shortcut is captured and the window closes, but it immediately appears a second time and I have to press the shortcut again.

This is already interesting. No wonder I can't reproduce it in trunk, otherwise I would have noticed right away )). Perhaps the problem is in applying a patch to an old version... I hope you can check the trunk, it will only take time to download and build (I have 5-10 minutes). You do not need to touch your existing installation.
Code: Text  [Select][+][-]
  1. git clone "https://gitlab.com/freepascal.org/lazarus/lazarus.git" "S:\laztrunk"
  2. cd /d "S:\laztrunk"
  3. echo --pcp=config > lazarus.cfg
  4. make clean all
  5. lazarus

Of course, git and fpc must be installed. The third line creates a special IDE file, specifying to store all the configuration in the "config" subfolder, so this will be an isolated installation.

Once Lazarus starts, install patch "git apply 346.diff" and rebuild as usual.

flowCRANE

  • Hero Member
  • *****
  • Posts: 885
Re: Ability to use the Win key to assign a specific IDE function
« Reply #34 on: October 19, 2024, 02:44:32 pm »
It's strange, I use them all the time (Win+Left/Right). Just curious, have you checked, for example, on the Explorer window?

Yes. To be sure that this shortcut is not reserved, I've checked it on few normal system windows, File Explorer included. And this shortcut do nothing on my PC. The Win+Up/Down shortcuts are reserved and are used to minimize/restore any window but Win+Left/Right do nothing with windows.

Quote
Informing about such a list is the task of the OS, and not all applications on the computer.

Of course, but nothing stand in the way to provide a link to Microsoft/Apple/etc. documentation with such list.

Quote
In addition, even Microsoft does not always document everything it does.

Well, in that case it is Microsoft's fault and we can do nothing with it (nothing more that an information that some shortcuts are reserved by the operating system).

Quote
The last thing I want is to have separate packages for each checkbox... Also, for the package to communicate with the IDE, we need to add the appropriate interfaces. I don't know, but I think this will require even more code. Let me remind that we are talking about only one one checkbox (which is shown by default on MacOS)...

I know. But this proposition would apply only if official support of shortcuts with Meta key is rejected. In my opinion, support of such shortcuts should be implemented, because this significantly expands the pool of shortcuts thanks to which IDE operation can become more convenient and better adapted to the user's hardware (keyboard).



No wonder I can't reproduce it in trunk, otherwise I would have noticed right away )).

I've added this patch to a fresh Lazarus 3.6 install (latest stable release), and the sources are a bit different than the ones in trunk. If everything works fine for you (in trunk), then there's no point in delving into this. I've already set up my keyboard shortcuts and I won't be changing them anytime soon, so that's no problem. I can always analyze the sources and fix the problem myself. But for now, there's nothing to worry about.
« Last Edit: October 19, 2024, 02:49:28 pm by furious programming »
Lazarus 3.6 with FPC 3.2.2, Windows 10 — all 64-bit

Working solo on a retro-style action/adventure game (pixel art), programming the engine from scratch, using Free Pascal and SDL.

 

TinyPortal © 2005-2018