[Ipe-discuss] Shortcut for toggling bookmarks panel?

Jacob Barandes jacob.barandes at gmail.com
Tue Jul 4 19:50:07 CEST 2023


This works excellently. Thanks to you both for your speedy solution!

On Tue, Jul 4, 2023 at 2:59 AM Otfried Cheong via Ipe-discuss <
ipe-discuss at lists.science.uu.nl> wrote:

> Very nice!
>
> Some remarks:
>
> 1. For a personal-use ipelet like this, I think it's fine to just put the
> shortcut inside the ipelet, like this:
>
> ----
> label = "Bookmarks"
>
> local visible = false;
>
> function toggle_bookmarks(model)
>    visible = not visible
>    model.ui:showTool("bookmarks", visible)
>    model:setBookmarks()
> end
>
> methods = {
>   { label = "toggle bookmarks", run=toggle_bookmarks },
> }
>
> shortcuts.ipelet_1_bookmark = "Ctrl+Alt+b"
> ----
>
> So you have all the definitions together.
>
>
> 2. self.ui:actionState("toggle_bookmarks")  works on Windows to get the
> current state, but not on Linux (where there is no way to get the current
> state).  The toggle in the menu is handled by Qt internally,
> MODEL:action_toggle_bookmarks() is not actually used on Qt.  If there is
> demand for it, I could implement the actionState to also work on Linux.
>
> 3. MODEL:setBookmarks() is probably needed on Windows to make sure the
> sizing of the Bookmark windows is right.  On Linux it doesn't really do
> anything.
>
> Cheers,
> Otfried
>
>
> On Tue, Jul 4, 2023, at 13:15, Bläsius, Thomas (ITI) via Ipe-discuss wrote:
> > Not sure whether this is the most elegant option, but you could solve
> > this via a small ipelet:
> >
> > -- bookmark.lua ------------------------------------------------------
> >
> > label = "Bookmarks"
> >
> > local visible = false;
> >
> > function toggle_bookmarks(model)
> >    visible = not visible
> >    model.ui:showTool("bookmarks", visible)
> >    model:setBookmarks()
> > end
> >
> > methods = {
> >   { label = "toggle bookmarks", run=toggle_bookmarks },
> > }
> >
> > ----------------------------------------------------------------------
> >
> > Then you can define the shortcut in the customization file like so:
> > shortcuts.ipelet_1_bookmark = "Ctrl+Alt+b"
> >
> >
> > Two additional comments:
> >
> > - I'm not sure how to check whether the bookmarks are currently
> >   visible. So the above solution will not know when you have changed the
> >   state via the ui and will potentially not toggle once (e.g., it tries
> >   to hide although it is already hidden). From the
> >   MODEL:action_toggle_bookmarks() method, it looks like one should be
> >   able to get the current state via something like
> >   self.ui:actionState("toggle_bookmarks") but I did not get this to
> >   work.
> >
> > - Also I am not sure what the model:setBookmarks() call is there for (I
> >   just copied it from the MODEL:action_toggle_bookmarks() method).
> >
> >
> > Jacob Barandes via Ipe-discuss <ipe-discuss at lists.science.uu.nl> writes:
> >
> >> I can't seem to find a way to bind a keyboard shortcut to toggle the
> >> bookmarks panel. There doesn't appear to exist a
> >> "shortcuts.toggle_bookmarks" property (or something like it) that I can
> set.
> >>
> >> I've checked the mailing list archives, but haven't found anything.
> >>
> >> Is there some way to do this that I'm not understanding?
> >>
> >> Please excuse any ignorance on my part, and thanks so much!
> >> _______________________________________________
> >> Ipe-discuss mailing list
> >> Ipe-discuss at lists.science.uu.nl
> >> https://mailman.science.uu.nl/mailman/listinfo/ipe-discuss
> > _______________________________________________
> > Ipe-discuss mailing list
> > Ipe-discuss at lists.science.uu.nl
> > https://mailman.science.uu.nl/mailman/listinfo/ipe-discuss
> _______________________________________________
> Ipe-discuss mailing list
> Ipe-discuss at lists.science.uu.nl
> https://mailman.science.uu.nl/mailman/listinfo/ipe-discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.science.uu.nl/pipermail/ipe-discuss/attachments/20230704/cf4c8af7/attachment.html>


More information about the Ipe-discuss mailing list