Never-mind folks. Turned out to be a simple bug, my menu-items word did
not correctly return the items of the menu passed in.

Fixing that solved my issue :)

Thanks,
Sankar

On 10/21/16 12:16 AM, Sankaranarayanan Viswanathan wrote:
> Hi,
>
> I'm trying to use the models vocabulary in order to implement keyboard
> navigation on menus. I still have some work to do, but right now I have
> something like this:
>
> :: prepare-menu ( menu -- )
>       f <model> :> model
>       menu menu-items :> items
>       items [ model add-connection ] each
>       model menu model<< ;
>
> Here menu is a gadget that contains menu-item gadgets. I have a
> model-changed on my menu-item like this:
>
> M: menu-item model-changed
>       swap value>> over = >>selected? relayout-1 ;
>
> My menu-items inherit from button and have a gesture handler setup like
> this:
>
> : activate-item ( item -- )
>       dup find-menu set-control-value ;
>
> : inactivate-item ( item -- )
>       f swap find-menu set-control-value ;
>
> M: menu-item handle-gesture
>       [
>           {
>               { [ over mouse-enter? ] [ nip activate-item ] }
>               { [ over mouse-leave? ] [ nip inactivate-item ] }
>               [ 2drop ]
>           } cond
>       ] 2keep call-next-method ;
>
> The problem I'm having is that the model-changed doesn't seem to trigger
> at all on the menu-items as I mouse over them. I expected the following
> sequence of events:
> (1) mouse-enter on menu-item
> (2) gesture handler updates value on menu model
> (3) menu model triggers model changed on all menu-item(s)
> (4) menu-item(s) update their appearances based on model value
>
> I know for sure that:
>    - the gesture handler is being invoked
>    - the menu gadget has its model slot populated
>
> Is there any reason the model-changed might not be triggered? I see that
> set-model first checks its "locked?" slot before doing anything. Does
> the UI set "locked?" to true during the event handling?
>
> Thanks,
> Sankar
>
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
>



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to