Or use GwtQuery. It helps you to query dom elements of a widget and modify 
them.

On Tuesday, July 15, 2014 6:28:30 PM UTC+2, Andy wrote:
>
> To be more specific, once you provide access to the MenuBar in your 
> subclass via something like:
>
> public native MenuBar getPrivateMenuBar() /*-{
>         return ... ;
> }-*/;
>
> you should be able to do:
>
> getPrivateMenuBar().getSelectedItem().getElement().scrollIntoView();
>
> Oh, but getSelectedItem() is protected! In that case I would just chain 
> them both in a native method. So in your subclass add:
>
> public native MenuItem getSuperSecretSelectedMenuItem() /*-{
>
> }-*/;
>
> Anyone know the rationale behind making getItems() and getSelectedItem() 
> protected in MenuBar?
>
> -Andy
>
> On Tuesday, July 15, 2014 12:15:45 PM UTC-4, Andy wrote:
>>
>> This is a common problem when trying to extend and modify GWT widgets. 
>> The easiest way to work around the use of private is to use JSNI.
>>
>> Here is an example 
>> <https://github.com/tractionsoftware/gwt-traction/blob/master/src/main/java/com/tractionsoftware/gwt/user/client/ui/TractionDialogBox.java#L196-L213>
>>  
>> from our gwt-traction library 
>> <http://tractionsoftware.github.io/gwt-traction/>.
>>
>> -Andy
>>
>> On Monday, July 14, 2014 1:40:06 PM UTC-4, chris-x...@db.com wrote:
>>>
>>> I'm working with a SuggestBox that produces a very large number of 
>>> suggestions on the first one or two chanracters.  I don't want an ugly list 
>>> that disappears off the bottom of the screen, so I've made the selection 
>>> display scroll by adding height and overflow to the CSS for 
>>> .gwt-SuggestBoxPopup .suggestPopupContent.
>>>
>>> It all works fine until I try to move through the selection list using 
>>> the keyboard.  The selected element does not scroll into view.  This is 
>>> obviously not going to pass any UX tests.
>>>
>>> I've subclassed SuggestBox.DefaultSuggestionDisplay in the hope of being 
>>> able to scroll the selected element into view as part of the 
>>> moveSelectionDown() and moveSelectionUp() methods.  But it seems that to 
>>> get to the Element selected I need access to the suggestionMenu field, and 
>>> that, for some reason, is private, so the subclass can't see it.
>>>
>>> Oh well, I guess I can copy the code from 
>>> SuggestBox.DefaultSuggestionDisplay and implement my own version.  This 
>>> sort of cut-n-paste inheritance goes against decent Java principles, but 
>>> it's only 280 lines or so.  No luck - SuggestBox.DefaultSuggestionDisplay 
>>> has a dependence on the private class SuggestBox.SuggestionMenu.
>>>
>>> At this point the only solution I can think of is to search the DOM for 
>>> an element with with a CSS class of "item-selected".  
>>>
>>> Does anyone know of a better solution?  I would be delighted to hear it.
>>>
>>> Chris
>>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

Reply via email to