Thread Rating:
  • 258 Vote(s) - 2.64 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ScrollBox間のスクロール連動
05-10-2017, 11:35 AM,
#2
RE: ScrollBox間のスクロール連動
ScrollBarを使えば、実現可能かと思います。
下記サンプルをご参考にしてみてください。

Code:
{curl 8.0 applet}
{curl-file-attributes character-encoding = "utf8"}

{define-proc {sync-scroll src:ScrollBox, obj:ScrollBox}:void
    {def src-vbar = {src.get-vscroll}}
    {def src-hbar = {src.get-hscroll}}

    {def obj-vbar = {obj.get-vscroll}}
    {def obj-hbar = {obj.get-hscroll}}
||--    {output vsbar2}
||--    {output hsbar2}

    {src-vbar.add-event-handler
        {on e:Adjustment do
            {obj-vbar.set-scroll-value {src-vbar.get-scroll-value}}
        }
    }

    {src-hbar.add-event-handler
        {on e:Adjustment do
            {obj-hbar.set-scroll-value {src-hbar.get-scroll-value}}
        }
    }
}

{def vb1 = {VBox}}
{def sb1 = {ScrollBox width = 100px, height = 100px, vb1}}
{def vb2 = {VBox}}
{def sb2 = {ScrollBox width = 100px, height = 100px, vb2}}

||--{def make-ev1 =
||--    {proc {arg-sb:ScrollBox}:EventHandler
||--        {return
||--            {on PointerScroll at sb:ScrollBox do
||--                {after 0s do
||--                    {arg-sb.scroll-to x = sb.horizontal-position, y = sb.vertical-position}
||--                }
||--            }
||--        }
||--    }
||--}
||--
||--{def make-ev2 =
||--    {proc {arg-sb:ScrollBox}:EventHandler
||--        {return
||--            {on pee:PointerEnvelopeEvent at sb:ScrollBox do
||--                {if pee.contents isa PointerMotion then
||--                    {after 0s do
||--                        {arg-sb.scroll-to x = sb.horizontal-position, y = sb.vertical-position}
||--                    }
||--                }
||--            }
||--        }
||--    }
||--}
||--
||--{sb1.add-event-handler {make-ev1 sb2}}
||--{sb1.add-event-handler {make-ev2 sb2}}
||--{sb2.add-event-handler {make-ev1 sb1}}
||--{sb2.add-event-handler {make-ev2 sb1}}

{for i:int = 1 to 20 do
    {vb1.add {Label i  & "行目"}}
    {vb2.add {Label i  & "行目"}}
}

{sync-scroll sb1, sb2}

{View
    {HBox
        sb1,
        sb2
    },
    visibility = "normal",
    {on WindowClose do
        {exit}
    }
}


Messages In This Thread
ScrollBox間のスクロール連動 - by Yudai-s - 05-09-2017, 01:20 PM
RE: ScrollBox間のスクロール連動 - by tdeng - 05-10-2017, 11:35 AM
Forum Jump:


Users browsing this thread:
1 Guest(s)

MyBB SQL Error

MyBB has experienced an internal SQL error and cannot continue.

SQL Error:
1017 - Can't find file: 'mybb_threadviews' (errno: 2)
Query:
INSERT INTO mybb_threadviews (tid) VALUES('1453')