[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kwrite-devel
Subject:    Re: Problem with automatic (?) keyboard shortcuts
From:       Andreas Pakulat <apaku () gmx ! de>
Date:       2013-09-11 22:53:36
Message-ID: CAExHGmQhLXCtTd1LmewX4g-dvtAtNBE6NeYRE7b0Ce-XVZXmdA () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Hi,

On Wed, Sep 11, 2013 at 10:21 PM, Alexander Neundorf <neundorf@kde.org>wrote:

> Hi,
>
> I'm not quite sure whether that's a feature of Qt or KDE or kate.
>
> In kate (I haven't noticed this in other places yet) keyboard shortcuts are
> somewhat automatically assigned.

E.g. if I use the Search&Replace plugin, it has a "Next" button, where Alt+N
> is the default shortcut. Good so far.
>

Those are generally called accelerators, not shortcuts. Though its possible
to configure keyboard shortcuts in KDE to be of the same type, accelerators
are generally either setup by the application author or automagically.


> If I search e.g. for "namespace", the result tab gets "namespace" as title,
> and now this tab is (automatically ?) assigned Alt+N, and the "Next"
> button is
> now Alt+X. This is not good.
> I think similar things happen if I have tabs enabled in the main editor
> area,
> they are also assigned shortcuts based on the filenames, taking away
> shortcuts
> from buttons.
> A similar issue is, if I open the Search&Replace plugin, as I said, "Next"
> has
> Alt+N. If I then open the Search bar, there is also a "Next" button, which
> usually also has Alt+N, but if this is already taken by Search&Replace, it
> gets Alt+X, maybe also other shortcuts depending on existing tab names.


> I think the shortcuts should not change,


Thats unrealistic since you have only a limited set of letters on your
keyboard. So the currently visible and available actions should definetly
be taken into account when setting up accelerators. In KDE apps this is
done by KAcceleratorManager and my recollection is that its algorithm tries
to keep the letters consistent and not change them randomly. It also tries
to assign them logically so they're easier to remember.


> I'm not sure how to improve this.
> Where does this automatic shortcut assignment happen ?
>

KAcceleratorManager is in kdelibs, but I'm not sure how its created at the
moment. I think this happens behind the scenes at least for xmlgui apps.


> Does this only happen to tabs ? Should it maybe simply be disabled there ?
>

I see in KDevelop's (kdevplatform/sublime/idealbutton.cpp) code that the
accelerator-generation for the buttons around the border (the toolview's)
are explicitly disabled. I guess the same thing makes sense to do for the
tabbar in Kate, I agree that for tab titles accelerators make little sense.


> What to do about the competing "Next" buttons from the search bar and the
> Search&Replace plugin ?


I think (but am not 100% sure) KAcceleratorManager respects statically
assigned accelerators. So if the text of a button or KAction is set as
&Next then Alt+N will always use that one. That way Kate could have at
least non-changing behaviour even if one Next button will still have an
Alt+X accelerator...

Andreas

[Attachment #5 (text/html)]

<div dir="ltr">Hi,<div class="gmail_extra"><br><div class="gmail_quote">On Wed, Sep \
11, 2013 at 10:21 PM, Alexander Neundorf <span dir="ltr">&lt;<a \
href="mailto:neundorf@kde.org" target="_blank">neundorf@kde.org</a>&gt;</span> \
wrote:<br> <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px \
#ccc solid;padding-left:1ex">Hi,<br> <br>
I&#39;m not quite sure whether that&#39;s a feature of Qt or KDE or kate.<br>
<br>
In kate (I haven&#39;t noticed this in other places yet) keyboard shortcuts are<br>
somewhat automatically assigned.</blockquote><blockquote class="gmail_quote" \
style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> E.g. if I use \
the Search&amp;Replace plugin, it has a &quot;Next&quot; button, where Alt+N<br> is \
the default shortcut. Good so far.<br></blockquote><div><br></div><div>Those are \
generally called accelerators, not shortcuts. Though its possible to configure \
keyboard shortcuts in KDE to be of the same type, accelerators are generally either \
setup by the application author or automagically.</div> <div> </div><blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex"> If I search e.g. for &quot;namespace&quot;, the result tab \
gets &quot;namespace&quot; as title,<br> and now this tab is (automatically ?) \
assigned Alt+N, and the &quot;Next&quot; button is<br> now Alt+X. This is not \
good.<br> I think similar things happen if I have tabs enabled in the main editor \
area,<br> they are also assigned shortcuts based on the filenames, taking away \
shortcuts<br> from buttons.<br>
A similar issue is, if I open the Search&amp;Replace plugin, as I said, \
&quot;Next&quot; has<br> Alt+N. If I then open the Search bar, there is also a \
&quot;Next&quot; button, which<br> usually also has Alt+N, but if this is already \
taken by Search&amp;Replace, it<br> gets Alt+X, maybe also other shortcuts depending \
on existing tab names. </blockquote><blockquote class="gmail_quote" style="margin:0 0 \
0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> <br>
I think the shortcuts should not change,</blockquote><div><br></div><div>Thats \
unrealistic since you have only a limited set of letters on your keyboard. So the \
currently visible and available actions should definetly be taken into account when \
setting up accelerators. In KDE apps this is done by KAcceleratorManager and my \
recollection is that its algorithm tries to keep the letters consistent and not \
change them randomly. It also tries to assign them logically so they&#39;re easier to \
remember.</div> <div> </div><blockquote class="gmail_quote" style="margin:0 0 0 \
.8ex;border-left:1px #ccc solid;padding-left:1ex">I&#39;m not sure how to improve \
this.<br> Where does this automatic shortcut assignment happen \
?<br></blockquote><div><br></div><div>KAcceleratorManager is in kdelibs, but I&#39;m \
not sure how its created at the moment. I think this happens behind the scenes at \
least for xmlgui apps.</div> <div> </div><blockquote class="gmail_quote" \
style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> Does this only \
happen to tabs ? Should it maybe simply be disabled there \
?<br></blockquote><div><br></div><div>I see in KDevelop&#39;s \
(kdevplatform/sublime/idealbutton.cpp) code that the accelerator-generation for the \
buttons around the border (the toolview&#39;s) are explicitly disabled. I guess the \
same thing makes sense to do for the tabbar in Kate, I agree that for tab titles \
accelerators make little sense.</div> <div> </div><blockquote class="gmail_quote" \
style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> What to do \
about the competing &quot;Next&quot; buttons from the search bar and the<br> \
Search&amp;Replace plugin ?</blockquote><div><br></div><div>I think (but am not 100% \
sure) KAcceleratorManager respects statically assigned accelerators. So if the text \
of a button or KAction is set as &amp;Next then Alt+N will always use that one. That \
way Kate could have at least non-changing behaviour even if one Next button will \
still have an Alt+X accelerator...</div> <div><br></div><div>Andreas</div><div> \
</div></div></div></div>



_______________________________________________
KWrite-Devel mailing list
KWrite-Devel@kde.org
https://mail.kde.org/mailman/listinfo/kwrite-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic