How do I unfocus the menu items in a menu?

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

How do I unfocus the menu items in a menu?

Paul Lynch
I have a pop-up menu (digit.Menu) which I generate programmatically.  When it appears, the first menu item is highlighted.  Is there a way to prevent that?  I would like the menu to appear will all menu items unhighlighted.  I tried menu.focusChild(null), but the dojo complained about the null.

     --Paul

Reply | Threaded
Open this post in threaded view
|

Re: How do I unfocus the menu items in a menu?

Paul Lynch
I've come up with two kludgey and not quite perfect solutions:

1) Use menu.focusChild(...) and give it a menu item that is hidden.  (menuitem.domNode.style.display = 'none').

2)  if (menu.focusedChild) {
      menu.focusedChild._setSelected(false);

Both of these have the same effect-- they remove the highlight, but the dotted line around the first menu item (which is still somewhere considered focused) is still present.
Reply | Threaded
Open this post in threaded view
|

Re: How do I unfocus the menu items in a menu?

postoffice
I'm talking totally speculatively here but I suspect the problem (from a dijit point of view) is that when the menu opens the focus has to shift to an element (for keyboard access and screen readers) and so an item has to be chosen - how else can you use the arrow keys for example to navigate the menu if an item doesn't have the focus to start with?

I appreciate that might not be an issue in your case - perhaps you could try using dijit.focus on the menu node itself? No idea if that would work tho.

Tom

On 28 September 2010 22:12, Paul Lynch <[hidden email]> wrote:

I've come up with two kludgey and not quite perfect solutions:

1) Use menu.focusChild(...) and give it a menu item that is hidden.
(menuitem.domNode.style.display = 'none').

2)  if (menu.focusedChild) {
     menu.focusedChild._setSelected(false);

Both of these have the same effect-- they remove the highlight, but the
dotted line around the first menu item (which is still somewhere considered
focused) is still present.
--
View this message in context: http://dojo-toolkit.33424.n3.nabble.com/How-do-I-unfocus-the-menu-items-in-a-menu-tp1597856p1598743.html
Sent from the Dojo Toolkit mailing list archive at Nabble.com.
_______________________________________________
FAQ: http://dojotoolkit.org/support/faq
Book: http://docs.dojocampus.org
[hidden email]
http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest


_______________________________________________
FAQ: http://dojotoolkit.org/support/faq
Book: http://docs.dojocampus.org
[hidden email]
http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Tom Elliott / mrtom / postoffice
Reply | Threaded
Open this post in threaded view
|

Re: How do I unfocus the menu items in a menu?

Karl Tiedt
CSS is your friend... all of dojo's focus appearances are state driven
and updated via CSS... change the CSS, it appears unfocused... of
course... then you have to kludge together a fix to make it appear
focused later... but you clearly already want to create extra work for
yourself that will likely make the page a bit more confusing to users
so... :P

-Karl Tiedt
_______________________________________________
FAQ: http://dojotoolkit.org/support/faq
Book: http://docs.dojocampus.org
[hidden email]
http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|

Re: How do I unfocus the menu items in a menu?

Paul Lynch
Ouch.  I am quite good at creating extra work for myself-- no doubt there.  However, if you look at Firefox's right-click context menu, I think you will see an example of what I was trying (and which I may give up trying) to achieve.  When you right click in the page, the context menu appears without any item in the menu selected.  However, the arrow keys still work.  As soon you down-arrow, the first item becomes selected.  In the case of my menu, where the first item is initially disabled, it looks particularly odd to have the initially selected item be a disabled item.

--Paul
Reply | Threaded
Open this post in threaded view
|

Re: How do I unfocus the menu items in a menu?

Karl Tiedt
Good argument, file an enhancement ticket at bugs.dojotoolkit.org I
suspect as was stated that a11y support is probably key to this design
method, but never know until you try :)

-Karl Tiedt
_______________________________________________
FAQ: http://dojotoolkit.org/support/faq
Book: http://docs.dojocampus.org
[hidden email]
http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|

Re: How do I unfocus the menu items in a menu?

Bill Keese-2
In reply to this post by postoffice
Tom is right, it's for a11y.   http://bugs.dojotoolkit.org/ticket/10716 is a related ticket but that's for menus spawning other (sub)menus, which is not work you're talking about IIUC.

On Wed, Sep 29, 2010 at 7:51 AM, Tom Elliott <[hidden email]> wrote:
I'm talking totally speculatively here but I suspect the problem (from a dijit point of view) is that when the menu opens the focus has to shift to an element (for keyboard access and screen readers) and so an item has to be chosen - how else can you use the arrow keys for example to navigate the menu if an item doesn't have the focus to start with?

I appreciate that might not be an issue in your case - perhaps you could try using dijit.focus on the menu node itself? No idea if that would work tho.

Tom

On 28 September 2010 22:12, Paul Lynch <[hidden email]> wrote:

I've come up with two kludgey and not quite perfect solutions:

1) Use menu.focusChild(...) and give it a menu item that is hidden.
(menuitem.domNode.style.display = 'none').

2)  if (menu.focusedChild) {
     menu.focusedChild._setSelected(false);

Both of these have the same effect-- they remove the highlight, but the
dotted line around the first menu item (which is still somewhere considered
focused) is still present.
--
View this message in context: http://dojo-toolkit.33424.n3.nabble.com/How-do-I-unfocus-the-menu-items-in-a-menu-tp1597856p1598743.html
Sent from the Dojo Toolkit mailing list archive at Nabble.com.
_______________________________________________
FAQ: http://dojotoolkit.org/support/faq
Book: http://docs.dojocampus.org
[hidden email]
http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest


_______________________________________________
FAQ: http://dojotoolkit.org/support/faq
Book: http://docs.dojocampus.org
[hidden email]
http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest



_______________________________________________
FAQ: http://dojotoolkit.org/support/faq
Book: http://docs.dojocampus.org
[hidden email]
http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest