r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[View] discuss view related issues

amacleod
1-Aug-2008
[7916x2]
I got it to scroll to my index point but I acn't find the fuction 
to update the scroll bar.
Got it!
my-scroll-panel/access/set-scroll-offset my-scroll-panel 0x-100
After trying every combo!!!
Graham
2-Aug-2008
[7918]
was the accessor scroll-panel ever incorporated into any vid widget?
amacleod
4-Aug-2008
[7919]
I got Cypher's tree widget to work with Anton's scroll-panel...sort 
of. Problem was tree widget uses cypher's scroll-panel style which 
of course works diferently from Anton's. Now I'm forced to use both 
and the tree scroll-panel does not display sliders correctly. 

I'm going to either need to find a way for the tree list to use Anton's 
scroll-panel or add the extra functionality to cypher's scroll-panel 
style...or start from scratch.
amacleod
7-Aug-2008
[7920]
New problem with Anton's scroll-panel style. 

When I select text I loose mouse scroll-wheel use and Keyboard scroll 
functionality.


Altme does not have this problem. I guess it's inherent to the style.
Henrik
7-Aug-2008
[7921]
sounds like a focus problem
amacleod
7-Aug-2008
[7922x3]
Yes. I tried a feel/event function to trap the up event on the mouse 
and it restores my scroll functionality but I'm not able to highlight 
now!
Should I look to patch the style or place the fix somewhere in my 
code?
I'm able to re-focus the scroll panel within my "clip" function (to 
save the highlighted text) but if I just click in a text area or 
highlight and not save it using hte clip function I can not get scrolling 
back.
BrettH
8-Aug-2008
[7925]
I have a similar problem re: scrolling, and I've tried the suggstions 
by amacleod without success, here I've copied a modified version 
of cookbook-scroller in the hope someone can suggest a solution.Hi, 
I'm trying to write a data entry form with many fields, this form 
is longer than a typical
monitor viewing area.

Creating the form is easy, but I cannot work out how to scroll the 
whole form 'up/down'

when the user TAB's out of the last showing field bottom and display 
the 'hidden' fields.

Rebol actually does TAB to the next field and accepts data entry 
but you cannot see it
without manually moving the scroll slider.


How do I programmatically make the form 'move' up/down ? and sync 
the slider ?

 I've tried "all" the example code I can find and none seem to do 
 the trick :-)


In the attached (modified cookbook-scroller.r) program I've added 
a few fields to illustrate the

problem. My need is for rapid data entry and using the mouse is really 
not a option, The program accepts user data, user TABS to navigate 
to next field, form slides as necessary, upon last field, data is 
saved, form cleared, cursor placed at first field, data entry continues.

Thanks for any ideas.

;; ===============================
  rebol ["cookbook-scroller2.r"]
  sub-panel: layout [
        across origin 5
        style label text bold right 60
        backcolor tan
        h2 leaf "Scrolling Sub Panel" return
        label "Name:" f1: field return
        label "Email:" f2: field return
        label "Info:" f3: area wrap return
        label "Month:"
        l1: text-list data system/locale/months return
        label "Day:" s1: slider 200x20 return
        label
        button "Submit"
        button "Cancel" [quit]
    ]

    out: layout [
        across
        h3 "Panel Scrolling Example" return
        space 0
        p1: box 300x300 coal frame black
        s1: scroller 16x300 [scroll-panel-vert p1 s1]
        return
        s2: scroller 300x16 [scroll-panel-horz p1 s2]
        return
    ]

    p1/pane: sub-panel

    scroll-panel-vert: func [pnl bar][
        pnl/pane/offset/y: negate bar/data *
            (max 0 pnl/pane/size/y - pnl/size/y)
        show pnl
    ]

    scroll-panel-horz: func [pnl bar][
        pnl/pane/offset/x: negate bar/data *
            (max 0 pnl/pane/size/x - pnl/size/x)
        show pnl
    ]

    update-panel: func [pnl vbar hbar] [
        pnl/pane/offset: 0x0
        s1/data: s2/data: 0
        vbar/redrag pnl/size/y / pnl/pane/size/y
        hbar/redrag pnl/size/x / pnl/pane/size/x
        show [pnl vbar hbar]
    ]

    update-panel p1 s1 s2
    view out
;; ============
amacleod
8-Aug-2008
[7926x2]
You will need to know the offset value of each face you tab into. 
You will also need to detect which ace is currently focused. (Do 
not know how is is done).

If you know these two things you can set the offset and "show" the 
face to junp to that location.


Also, I do not know if all faces can be tabbed into such as your 
month list face..
If your just trying to avoid mouse use you can add keyboard control 
of scroll (page down, page up, arrow keys etc.)
BrettH
8-Aug-2008
[7928]
Thanks for your input.


 I removed the Month list type and replaced with  fields. Tab does 
 visit each one in turn, and accepts data enty even tho their not 
 visible. ( until you slide)

eg:
        label "Name:" f1: field return
         label "Email:" f2: field return
         label "Info:" f3: area wrap return
	 label "More info: " f4: field return
	 label "Even more ;" f5: field return


As for the  'offset' info you mention, thats probably the key to 
the problem, and like you I have NO idea how

to get this !!  I've tried various code ideas attached to the TAB 
field exit without success.


I'm not trying to avoid mouse use , I just want to program the data 
entry flow for user comfort, 
the user should still be able  to use the mouse as needed.


I think REBOL is a very interesting product but it does seem to have 
many 'holes' in fundemental GUI handling :-),

on the one hand it offers the very easy to make GUI interface tool, 
then stuffs up drop-down-lists, sliders, TAB control,
etc.
Graham
8-Aug-2008
[7929]
we are waiting for Vid 3.4
BrettH
8-Aug-2008
[7930]
I've been "waiting" for the "perfect development tool" since 1964 
!! :-)
BrettH
9-Aug-2008
[7931]
Solved !!! Took a bit of fiddling around, but now the form moves 
down thru the fields

as the user tabs out of a filed, and slides back to first field on 
tab out of last field.
Mouse positioning via scroll bar still working.

I left the trace print code in so you can observe its operation.


See the comments in teh code for the changes I made to cookbook-scroller.r

Now to try it with my own form.

;; ==============================================
rebol ["cookbook-scroller-2-1.r"
       author "Brett Hallett 2008 "
	comment  { 

    Modified  cookbook-scroller.r program  to code automatic scrolling 
    of fields on TAB,

    allows the form to have fields off the viewable page and automatically 
    scroll up/down 
	   as the user leaves a field using TAB.

    -- display field position on TAB -- eg:  print  [ "f1 "  f1/offset] 
     ( for testing only !)

    -- scroll-panel-vert func modified with extra parameter  ( a fields 
    y offset )

    -- compute offset value before calling scroll-panel-vert in out: 
    layout ( stops scroller aborting !)
	  }
	 ]

 sub-panel: layout [
        across origin 5
        style label text bold right 60
        backcolor tan
        h2 leaf "Scrolling Sub Panel" return

        label "Name:" f1: field [ print  [ "f1 "  f1/offset]        scroll-panel-vert 
        p1 s1 f1/offset/y ] return

        label "Email:" f2: field  [ print  ["f2 " f2/offset]          scroll-panel-vert 
        p1 s1 f2/offset/y ] return

        label "Info:" f3: area wrap [ print  ["f3 " f3/offset]     scroll-panel-vert 
        p1 s1 f3/offset/y ] return
	

  label "More info: " f4: field [ print  ["f4 " f4/offset]      scroll-panel-vert 
  p1 s1 f4/offset/y ] return

  label "Even more ;" f5: field [ print   ["f5 " f5/offset ]  scroll-panel-vert 
  p1 s1 f1/offset/y 
							print "write collected data"
							clear-fields sub-panel ] return

  ;; notice how the first field offset is used to set the scroll position 
  on last field exit
	 
        button "Submit" [ print "Press Submit "]
        button "Cancel" [ print "Quit" quit]
    ]

    out: layout [
    
        across
        h3 "Panel Scrolling Example" return
        space 0
        p1: box 300x300 coal frame black

        s1: scroller 16x300 [scroll-panel-vert p1 s1  ( s1/data * (max 0 
        p1/pane/size/y - p1/size/y)) ]
				;; compute offset value before calling scroll-panel-vert
        return
        s2: scroller 300x16 [scroll-panel-horz p1 s2]
        return

    ]

    p1/pane: sub-panel


;; scroll-panel-vert modified with extra parameter : fldoffset ( 
the y offset of the TAB'ded out of field )
      scroll-panel-vert: func [pnl bar fldoffset][
        pnl/pane/offset/y: negate fldoffset
	 print ["pnl-vert " pnl/pane/offset/y]
        show pnl

    ]

    scroll-panel-horz: func [pnl bar][

        pnl/pane/offset/x: negate bar/data * (max 0 pnl/pane/size/x - pnl/size/x)
        show pnl
    ]

    update-panel: func [pnl vbar hbar] [
        pnl/pane/offset: 0x0
        s1/data: s2/data: 0
        vbar/redrag pnl/size/y / pnl/pane/size/y
        hbar/redrag pnl/size/x / pnl/pane/size/x
        show [pnl vbar hbar]
    ]
   
    update-panel p1 s1  s2
     view out
Graham
10-Aug-2008
[7932]
Good start .. now to get back tabbing to work, and also prevent scrolling 
when the bottom of the form is visible!  :)
BrettH
11-Aug-2008
[7933]
Nitt Picker !!  But you right its a bit clunky at the moment, its 
only saving grace its that the data entry field remains in a static 
position !! :-)
BrettH
16-Aug-2008
[7934]
I had another look at the scroller problem, and I'm beginning to 
see that it really does not work !
eg:

 == the scroll bar does not 'follow' the offset in the pane even when 
 its new position is calculated and set

        == does not seem to be anyway to adjust the size of the moving bar 
        itself. Unable to find any documentation.

 == even with calculating the length of the (sliding) form against 
 its (viewable) panel length, 
           the offset 'action' for TAB 

           is not consistent in that the last form field is not always viewable 
           by the tab action 

           -- seems to be dependent upon the relationship between form length 
           and panel size which you can adjust manually 

              but thats hardly a useful solution. When you add a field the whole 
              scroller stops working. ( Flaky !)
        == pretty disapointing really.


Whats needed is a scroller that can be defined to operate with any 
pane and automatically following the field tabbing
in that pane without coding required. "Follow the source --Luke!"

Heres the latest code effort !

;;======================================================
rebol ["cookbook-scroller-2-11.r"
       author "Brett Hallett 2008 "
	comment  { 

    Modified  cookbook-scroller.r program  to code automatic scrolling 
    of fields on TAB,

    allows the form to have fields off the viewable page and automatically 
    scroll up/down 
	   as the user leaves a field using TAB.

    -- display field position on TAB -- eg:  print  [ "f1 "  f1/offset] 
     ( for testing only !)

    -- scroll-panel-vert func modified with extra parameter  ( fields 
    y offset )

    -- compute offset value before calling scroll-panel-vert in out: 
    layout
	   -- move trace to func print-pos for easier modification
	  }
	 ]

 sub-panel: layout [  size 300x350
        across origin 0
        style label text bold right 60
        backcolor green
        h2 leaf "Scrolling Sub Panel" return

        label "Name:" f1: field       [ print-pos   "f1 " f1/offset   scroll-panel-vert 
        p1 s1 f1/offset/y ] return

        label "Email:" f2: field        [ print-pos   "f2 " f2/offset   scroll-panel-vert 
        p1 s1 f2/offset/y ] return

        label "Info:" f3: area 199x115 wrap  [ print-pos  "f3 " f3/offset 
          scroll-panel-vert p1 s1 f3/offset/y ] return
	

  label "More info: " f4: field   [ print-pos   "f4 " f4/offset   scroll-panel-vert 
  p1 s1 f4/offset/y ] return

 ;;  label "More info: " f41: field   [ print-pos   "f41 " f41/offset 
   scroll-panel-vert p1 s1 f41/offset/y ] return

  ;;label "More info: " f42: field   [ print-pos   "f42 " f42/offset 
    scroll-panel-vert p1 s1 f42/offset/y ] return

  label "Last  ;" f5: field [ print-pos   "f5 " f5/offset   scroll-panel-vert 
  p1 s1 0 
							print "write collected data"
							clear-fields sub-panel ] return 

 ;; notice how the  offset of zero is used to set the scroll position 
 to top of form on last field exit
	below
	pad 5
	below
    ]

btn-panel: layout [
        across
	 button "Submit" [ print "Press Submit "]
        button "Cancel" [ print "Quit" quit]
	]
	
main-form: layout [
        across
        h3 "Panel Scrolling Example" return
        space 0
        p1: box 	  300x250 coal frame black

        s1: scroller 16x250 [scroll-panel-vert p1 s1  ( s1/data * (max 0 
        p1/pane/size/y - p1/size/y))  ]
				;; compute offset value before calling scroll-panel-vert
        return
	  p2: box 300x50

    ]
 
print-pos: func [ fld pos ] [ print ["print-pos: "  fld  pos]]


;; scroll-panel-vert modified with extra parameter : fldoffset ( 
the y offset of the TAB'ded out of field )

scroll-panel-vert: func [pnl bar fldoffset][
	
	;; print [ "slider:" ( (max 0 p1/pane/size/y - pnl/size/y))]

        if fldoffset < ( (max 0 p1/pane/size/y - pnl/size/y))  [ pnl/pane/offset/y: 
        negate fldoffset ]
	
	;; print ["pnl-vert " pnl/pane/offset/y  fldoffset]
        show pnl

    ]

update-panel: func [pnl vbar  pnl2] [
        pnl/pane/offset: 0x0
        s1/data:  0
        vbar/redrag pnl/size/y / pnl/pane/size/y
        pnl2/pane/offset: 0x0
        show [pnl vbar pnl2]
    ]
   
    p1/pane: sub-panel
    p2/pane: btn-panel
   
    update-panel p1 s1  p2
  
    view main-form

;; ==========================
Anton
18-Aug-2008
[7935x2]
Hi guys. 

amacleod, I see the scroll-panel problem, will look into it shortly.
amacleod, the "selected text prevents scrolling in scroll-panel" 
problem is not the fault of scroll-panel.

demo-scroll-panel.r shows this problem because I didn't want to make 
it too complex, by including the necessary global event handler to 
handle scroll events on non-focused scrolling faces (such as scroll-panels). 
I do have a demo somewhere which has the necessary global event handler 
somewhere... at least style-gallery.r uses it.
amacleod
18-Aug-2008
[7937]
Thanks Anton.
Anton
18-Aug-2008
[7938]
Are you developing specifically for Windows ? (I just found a bug 
in scroll-wheel-handler.r on linux.)
amacleod
18-Aug-2008
[7939x2]
Just checked Style-Gallery.r. Yes, it scrols when high-lighted
For now!. Windows will surfice.
Anton
18-Aug-2008
[7941]
Ok, very good. :)

I thought I might try to analyse the Cyphre's tree + Anton's scroll-panel 
problem you spoke of before.
Did you just happen to make a minimal demo showing the problem ?
amacleod
18-Aug-2008
[7942x2]
I got tree wiget to work but I had to include cypher's scroll panel 
as well. The problem with his slders not rendering I just realized 
was probably due to my not including his other stlyes he uses to 
raw the arrows etc.

Unless you mean to get tree widget to use your style it was just 
a nameing problem if i remembr correctly. 

I went with a different solution and I am no longer using tree widget 
for he app.
raw=draw
Anton
18-Aug-2008
[7944]
Ok, you've found another solution for now, but it's still interesting 
to me if there is a problem mixing styles from different authors. 
This 'should' (ought to) be possible without any conflict.
amacleod
18-Aug-2008
[7945]
Anton, I'm looking at Style-Gallery...
Should I include "focus-on-down-event-handler.r" in my app? 

And what about "scroll-wheel-handler.r" Does this add functionality?
Anton
18-Aug-2008
[7946x5]
Yes and yes. They both bring benefits. Both are global handlers.
In style-gallery.r, if you go to Global Options / Handlers, you can 
enable / disable each of the global event handlers (by pressing a 
toggle button) to see the effect on the user interface dynamically.
I've just uploaded 
gui/demo-scroll-wheel-handler.r  and
gui/scroll-wheel-handler.r  is still there of course.
demo-scroll-wheel-handler.r  shows how to
- get and initialise the scroll-wheel-handler
- create and open your windows
- wait for events (VIEW does this)
- clean up the scroll-wheel-handler
do http://anton.wildit.net.au/rebol/gui/demo-scroll-wheel-handler.r
Henrik
18-Aug-2008
[7951x4]
Anton, link to http://anton.wildit.net.au/rebol/gui/demo-scroll-area.r
is dead
I'm playing around with scroll-area. SET-FACE/NO-SHOW behaves like 
SET-FACE.
also no action block is available to run, as far as I can see.
is it possible to turn off the horizontal scroller?
Anton
18-Aug-2008
[7955]
Uploaded demo-scroll-area.r.
Henrik
18-Aug-2008
[7956]
thanks
Anton
18-Aug-2008
[7957x2]
Let me check out horizontal scroller ...
I haven't programmed scrollers to be easily optional (though it's 
on to-do list).
Henrik
18-Aug-2008
[7959]
ok. would it be possible to turn on wrap? for the area, so the scroller 
might ignore horizontal movement?
Anton
18-Aug-2008
[7960]
Have you tried setting wrap? already ?
Henrik
18-Aug-2008
[7961]
I didn't yet study which face directly to set. I assume the text 
area is inside a pane?
Anton
18-Aug-2008
[7962x4]
Yes. (This is in scroll-area.r script header, at the top of the Notes..)
my-scroll-area/pane/1  or my-scroll-area/area/para/wrap?: true
Hmm.. it works, but there is an unwanted few pixels scroll when typing 
first line is wrapped.
Let me look why...