clj-commons/seesaw

(scroll! area :to :top) not always working

mmower opened this issue · 4 comments

Hi.

I'm following along with the REPL tutorial using Clojure 1.6.0 and SeeSaw 1.4.5-STABLE.

Trying to use (scroll! area :to :top) works one or twice but mostly does nothing. There's no error, the function returns the 'area' JTextArea as expected, but the scroll to the top does not happen.

Can anyone else reproduce this?

Best,

Matt

Actually it seems that the scroll! function is not, in general, reliable since I've found that :to :bottom and :to [:line 50] are also pretty unreliable for me.

It seems to work consistently for me on OSX. Try forcing the call onto the UI thread in case it's Swing threading weirdness: (invoke-now (scroll! area :to :top))

If anyone is interested, I stumbled upon a possible workaround (this worked for me twice).
After the area is wrapped in a scrollable, I called (scroll! area :to [:line 0]), then calling (scroll! area :to :bottom) and (scroll! area :to :top) both worked. Maybe the widget just needs to be initialized by scrolling to line 0 first?

I was having this problem as well. In my case I was trying to do the scroll! inside of a b-do. Kind of like this

(bind 
    my-atom
    (property my-text-component :text)
    (b-do [_] (scroll! my-text-component :to :top))

What I had to do was

(bind 
    my-atom
    (b-do [t] 
      (text! my-text-component t)
      (scroll! my-text-component :to :top))