in reply to Re^2: Tk::BrowseEntry listbox scrollbar with Mousewheel on Windows
in thread Tk::BrowseEntry listbox scrollbar with Mousewheel on Windows

Hi,

What did I miss? You only want to yview and not select? Can you not copy WheelsUp and do yview instead of updown?

update:

If you remove your bind call and replace it with  $mw->focusFollowsMouse; then the Tk::Listbox natural wheel bindings work to scroll the listbox up down without changing the selection

But if focusFollowsMouse is too much focus flipping, simply give the focus to the listbox when the button is pressed

$b->Subwidget('arrow')->configure( -command => [ 'focus', $b->Subwidget('slistbox') ], );

Also, $mw->WidgetDump can help you peek inside

Replies are listed 'Best First'.
Re^4: Tk::BrowseEntry listbox scrollbar with Mousewheel on Windows
by perltux (Monk) on Apr 04, 2017 at 00:15 UTC
    I don't like switching on 'focusFollowsMouse' on Windows as it has too many side effects, but many thanks for your last suggestion ($b->Subwidget('arrow')->configure(-command=>['focus',$b->Subwidget('slistbox')]);) which works fine, except for two minor flaws:

    - when clicking on the entry box the listbox also opens but in that case without functioning mousewheel

    - the currently selected option is now underlined (which is actually quite nice) except the first time the pop-up is opened for some reason always the first option is underlined, even if the entry field contains a different selected option.


    Bingo! Your suggestion has put me on the right track and I have now come up with an even better solution that eliminates the first one of the two minor flaws listed above:

    $b->Subwidget('slistbox')->bind('<Enter>', sub{$b->Subwidget('slistbox')->focus()});

    Now I only still have to find a solution for the wrong underline the first time the listbox pops up.

      Bingo! bind('<Enter>'

      Nice! This will scroll by wheel even if focus is on the scrollbar

      $b->Subwidget('slistbox')->toplevel->bind( '<Enter>', [ $b->Subwidget('slistbox'), 'focus' ] ## no closure here );

      Now for the underline, here is how you figure that out

      install Tk::WidgetDump, and add  $mw->WidgetDump; to your program before MainLoop

      Then run the program, and click on the WidgetDump window

      double click the 'listbox' entry which pops up

      'Widget Info for Tk::Listbox...' where you click on the first "Option Switch" which pops up

      'Edit config' which lets you edit the configuration live,

      So change the value, then go back to your mainwindow and see if the underline is still there

      Then simply incorporate that into your program

      :)

        You are right I missed the scrollbar, but:
        $b->Subwidget('slistbox')->toplevel
        can be simply written as:
        $b->Subwidget('choices')

        I figured out the underline is coming from the 'activate' method of Listbox.

        I don't really get the point of the 'activate' method, I'll have to think about how to deal with it.
        I wish I could simply deactivate the 'activate' method altogether... ;)