linuxxlibmotif

Motif: How to move Scroll Bar automatically without user intervention


I have a scrolled window in my application, in which I have created a drawing area widget. In the drawing area, I have placed multiple images. When the user enters information about an image in a search box, the appropriate image gets highlighted.

My problem is how do I get the application to scroll automatically to the highlighted Image box without the user using the scroll bar. The scrolledwindow should automatically move the view region, to display the region where the highlighted Image is present.

The scrolling policy used on the scrolled window is XmAUTOMATIC.

Any pointers would be greatly appreciated.Thanks in advance.


Solution

  • Try XmScrollVisible() if this does not work then you will need to:

    1. Find out the size of the work area.
    2. Find out the size and position of the clip window.
    3. Find out the max/ min values for the horizontal scrollbar.
    4. Use XmScrollBarGetValues() for the horizontal scrollbar to get its position within the max/min values.
    5. Do some math magic to determine how much to move the horizontal scrollbar to get the work area to show through the clip window.
    6. Call XmScrollBarSetValues() with Notify = True.
    7. Repeat for the Vertical scrollbar.
    

    HTH