Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing Keybindings #17

Open
2 of 8 tasks
raw-bacon opened this issue Jan 27, 2022 · 3 comments
Open
2 of 8 tasks

Missing Keybindings #17

raw-bacon opened this issue Jan 27, 2022 · 3 comments

Comments

@raw-bacon
Copy link
Owner

raw-bacon commented Jan 27, 2022

  • Change page background
  • Toggle snapping
  • Zoom 100
  • Fill
  • Change eraser type
  • Paired pages
  • Color selector
  • Half-page scrolling
@BertrandSim
Copy link

Hello, I'm a user of your plugin. For toggle snapping, I have the following:

function clickGridSnap(enabled)
  app.uiAction({
    ["action"] = "ACTION_GRID_SNAPPING", 
    ["group"] = "GROUP_GRID_SNAPPING", 
    ["enabled"] = enabled
  })
end

in api.lua, and

  GridSnap = {
    description = "Grid Snapping",
    buttons     = {"g"},
    modes       = {"visual", "shape"},
    call        = clickGridSnap
  },

  GridSnapOff = {
    description = "Grid Snapping Disable",
    buttons     = {"<Shift>g"},
    modes       = {"visual", "shape"},
    call        = function() clickGridSnap(false) end
  },

in keybindings.lua.

The intention was for 'ag' and 'aG' to enable/disable grid snapping respectively.

However, I found that both 'ag' and 'aG' toggles the grid snapping, rather than turning them on or off.

I've tried to find a fix, such as removing the "group" argument in clickGridSnap, but to no avail. Do you have any idea?

@Rapha149
Copy link

Rapha149 commented Sep 7, 2024

Hello, I'm a user of your plugin. For toggle snapping, I have the following:

function clickGridSnap(enabled)
  app.uiAction({
    ["action"] = "ACTION_GRID_SNAPPING", 
    ["group"] = "GROUP_GRID_SNAPPING", 
    ["enabled"] = enabled
  })
end

in api.lua, and

  GridSnap = {
    description = "Grid Snapping",
    buttons     = {"g"},
    modes       = {"visual", "shape"},
    call        = clickGridSnap
  },

  GridSnapOff = {
    description = "Grid Snapping Disable",
    buttons     = {"<Shift>g"},
    modes       = {"visual", "shape"},
    call        = function() clickGridSnap(false) end
  },

in keybindings.lua.

The intention was for 'ag' and 'aG' to enable/disable grid snapping respectively.

However, I found that both 'ag' and 'aG' toggles the grid snapping, rather than turning them on or off.

I've tried to find a fix, such as removing the "group" argument in clickGridSnap, but to no avail. Do you have any idea?

That's because in the current version of Xournal++ the action ACTION_GRID_SNAPPING toggles the grid snapping, as can be seen in Control.cpp#L910. However, since the last release, this behaviour has changed. As you can see in ActionProperties.h#L237 in the currently newest version on Github, it now uses the enabled flag (it's a different class now because the whole action system got restructured).
Therefore, if you install the nightly release or install the unstable versions from your package manager if possible (e.g. the Unstable PPA for Ubuntu) or compile Xournal++ yourself, you can then use your api snippet to get the on/off and not the toggle behaviour. However, if you do this (as I have done, for other reasons) you will have to rewrite some other parts of the api as well because other things have changed too.

Btw, the group argument is only used for debug purposes right now, it doesn't have any impact on the action, at least to my knowledge.

@BertrandSim
Copy link

BertrandSim commented Oct 5, 2024

That's because in the current version of Xournal++ the action ACTION_GRID_SNAPPING toggles the grid snapping, as can be seen in Control.cpp#L910. However, since the last release, this behaviour has changed. As you can see in ActionProperties.h#L237 in the currently newest version on Github, it now uses the enabled flag (it's a different class now because the whole action system got restructured).

Appreciate the reply. This is very helpful! Also the differences between the current and nightly releases were clearly pointed out. Cheers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants