NSScrollerView Problem

  • I have a custom view inside an NSScrollView.  When I drag the scroll
    bar, the view scrolls appropriately.  When I click in the empty space
    beside the scroll bar, the view scrolls appropriately.  When I click
    on the scroll arrows, they highlight, but the view does NOT scroll.
    At all, neither by clicking nor clicking-and-holding.

    BTW, the scrollview is NOT a subclass, mouseDown: is NOT overridden.
    The custom child view DOES have custom mouseDown: and keyDown:
    methods, and they respond appropriately.  The scroll view is not
    focusable and does not handle key events.

    I have also tried "Move To Front" in IB on the scroll view; it made
    no difference.

    The entire thing *used* to work appropriately.  What could I have
    possibly done to fubar only *part* of the scroller?

    Thanks!
    randy
  • Ask yourself what those buttons on the scroll bar do?  They scroll line by line or page by page.  Now ask yourself, how does the framework know how far to scroll in order to scroll line by line ?  Is it possible that you have set the verticalLineScroll to zero or allowed it to remain zero ?  http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Cla
    sses/NSScrollView_Class/Reference/Reference.html#//apple_ref/occ/instm/NSSc
    rollView/lineScroll
      lineScroll  Returns the vertical line scroll amount: the amount by which the receiver scrolls itself vertically when scrolling line by line, expressed in the content view’s coordinate system.
      - (float)lineScroll
      Discussion  This amount is used when the user clicks the scroll arrows on the vertical scroll bar without holding down a modifier key. As part of its implementation, this method calls verticalLineScroll.
      Note that a scroll view can have two different line scroll amounts: verticalLineScroll and horizontalLineScroll. Use this method only if you can be sure they’re both the same; for example, you always use setLineScroll:, which sets both amounts to the same value.
      Availability
      Available in Mac OS X v10.0 and later.
      See Also
      – setLineScroll:

      – verticalPageScroll

      – horizontalPageScroll
  • At 10:45 AM -0700 8/28/07, Erik Buck wrote:

    > Ask yourself what those buttons on the scroll bar do?  They scroll
    > line by line or page by page.  Now ask yourself, how does the
    > framework know how far to scroll in order to scroll line by line ?
    > Is it possible that you have set the verticalLineScroll to zero or
    > allowed it to remain zero ?

    OK, the verticalLineScroll is indeed zero.  I ran a previous version
    that behaved correctly and the value was 10.  Ok, now we're getting
    somewhere!  Except...

    NOWHERE is any of the setLineScroll methods called.  Not in the
    current, broken version NOR the previous, working version.  Is that
    value defaulted to somehow/someway that is non-obvious (or obvious,
    and I'm just being thick)?

    There's clearly something going on here I don't understand.  I put in
    some logging calls:

    NSLog(@"[[self superview] superview] class is %@.", [[[self
    superview] superview] class]);
    NSLog(@"lineScroll is %f.", [[[self superview] superview] verticalLineScroll]);
    [[[self superview] superview] setVerticalLineScroll:50.0];
    NSLog(@"lineScroll is %f.", [[[self superview] superview] verticalLineScroll]);

    in the version that works.  Here's the output:

    2007-08-28 15:02:51.590 Cliq[20133] [[self superview] superview]
    class is NSScrollView.
    2007-08-28 14:02:51.590 Cliq[20133] lineScroll is 0.000000.

    Hmmm, but the scrolling works, even though the value is 0.  What?

    (gdb) p (float)[[[self superview] superview] verticalLineScroll]
    $2 = 10

    But wait a minute; the object in GDB doesn't think the value is 0!
    Let's try setting it to something manually:

    [[[self superview] superview] setVerticalLineScroll:50.0];
    NSLog(@"lineScroll is %f.", [[[self superview] superview] verticalLineScroll]);

    produces:

    2007-08-28 14:03:22.961 Cliq[20133] lineScroll is 0.000000.

    AND the scrolling is now broken.  Similar behavior occurs if I change
    the value from within gdb, using:

    (gdb) call (void)[[[self superview] superview] setVerticalLineScroll:50.0];
    (gdb) p (float)[[[self superview] superview] verticalLineScroll]
    $3 = 0

    Where does the initial value of 10 come from?  And why does it break
    completely when I manually set it to 50?  And why the difference
    between output from the application versus from within gdb?  (The gdb
    command were issued while sitting at breakpoints set on the NSLog()
    calls above, so it was in the exact same place in the code for both.)

    This is all in the previous version, BTW.  I'm still trying to figure
    out where/how it got changed in the current version.
  • On Aug 29, 2007, at 00:46 , Randall Meadows wrote:

    > I have a custom view inside an NSScrollView.  When I drag the
    > scroll bar, the view scrolls appropriately.  When I click in the
    > empty space beside the scroll bar, the view scrolls appropriately.
    > When I click on the scroll arrows, they highlight, but the view
    > does NOT scroll. At all, neither by clicking nor clicking-and-holding.
    >
    > BTW, the scrollview is NOT a subclass, mouseDown: is NOT
    > overridden. The custom child view DOES have custom mouseDown: and
    > keyDown: methods, and they respond appropriately.  The scroll view
    > is not focusable and does not handle key events.
    >
    > I have also tried "Move To Front" in IB on the scroll view; it made
    > no difference.
    >
    > The entire thing *used* to work appropriately.  What could I have
    > possibly done to fubar only *part* of the scroller?
    >

    Are you sure Line Amount (relevant to your problem) and Page Context
    are set properly in the Attributes pane of the NSScrollView inspector
    in IB? In Xcode 2.4.1/IB 2.5.4 my NSScrollView obeys these settings
    nicely, with no code/subclassing required.

    ScottB
previous month august 2007 next month
MTWTFSS
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31    
Go to today