Your code didn't run for me as is, you have to set ``nodes`` to a value
first.

Also, I don't understand why ``draw`` is making a new ``<scroller>``
instead of just adding the new node to the existing scroller?



On Sun, Sep 18, 2016 at 5:33 AM, Georg Simon <georg.si...@auge.de> wrote:

> The code below is a useless program.
> It's only purpose is to show my question.
>
> By pressing INSERT I add new nodes until the scroller appears.
>
> By using ← or → I can see the scroller work.
>
> Pressing INSERT triggers the content of the filled-cell of
> "dialog < frame" to be overwritten by "draw".
> "draw" triggers "node-gadget => model-changed" which calls
> "scroll>gadget".
> But scrolling doesn't work after INSERT.
>
> I guess that rendering happens after "scroll>gadget".
>
> How can I make scrolling work in this case ?
> -----------------------------------------------------
> USING:
>     accessors colors.constants kernel
>     math math.parser models namespaces sequences
>     ui ui.gadgets ui.gadgets.borders ui.gadgets.frames
>     ui.gadgets.grids ui.gadgets.labels ui.gadgets.packs
>     ui.gadgets.scrollers
>     ui.gestures ui.pens.solid
>     ;
> IN: test-script
>
> SYMBOL: nodes
>
> : add-node ( -- n )
>     nodes get dup length [ suffix nodes set ] keep
>     ;
> TUPLE: node-gadget < border
>     number
>     ;
> M: node-gadget model-changed
>     swap value>> over number>> =
>     [ dup scroll>gadget COLOR: black <solid> ] [ f ] if
>     >>boundary relayout-1
>     ;
> : <node-gadget> ( n model -- gadget )
>     swap [ number>string <label> node-gadget new-border ] keep
>     >>number { 22 22 } >>size dup rot add-connection
>     ;
> TUPLE: dialog < frame
>     ;
> CONSTANT: chart-cell { 0 1 }
>
> : draw ( dialog n -- dialog' )
>     swap dup model>> <shelf>
>     nodes get [ pick <node-gadget> ] map add-gadgets nip
>     <scroller> chart-cell grid-add [ set-control-value ] keep
>     ;
> : go ( dialog offset -- )
>     over control-value + nodes get length rem
>     swap set-control-value
>     ;
> dialog
> H{
>     { T{ key-down { sym "INSERT" } } [ add-node draw drop ] }
>     { T{ key-down { sym "LEFT" } } [ -1 go ] }
>     { T{ key-down { sym "RIGHT" } } [ 1 go ] }
>     }
> set-gestures
>
> : <dialog> ( -- gadget )
>     1 2 dialog new-frame chart-cell >>filled-cell
>     "Press ← or → to navigate. Press INSERT to add a number."
>     <label> { 5 9 } <border> { 0 0 } grid-add
>     0 [ <model> >>model ] keep draw
>     ;
> 5 [ add-node drop ] times [ <dialog> "dialog" open-window ] with-ui
>
> ------------------------------------------------------------
> ------------------
> _______________________________________________
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>
------------------------------------------------------------------------------
_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to