dow@PRESTO.IG.COM (Christopher Dow) (01/26/91)
I have a window which has an area in which text is edited(not a widget because of the nature of the editing), two scrollbars which aren't window decorations, a button, and an area with some labels: +--------------------------------------------------------------------------+ | Menu Menu Menu .... | +--------------------------------------------------------------------------+ | Informational Stuff | +--------------------------------------------------------------------------+ | Label | | | | Label | Editing area | | | Label | | | | Label | | | | Label | ScrollBars---------->| | | Label | | | | | Label | V | | +-------------+------------------------------------------------------------+ | Button | | | +-------------+------------------------------------------------------------+ When the mouse is over the editing area, I set the cursor to be an i-beam. When it's not I set the cursor to be an arrow. The only problem is, that I don't get informed when the mouse moves over the scroll bars or the button, so if it moves from the editing area to the scroll bars, it stays an i-beam, which looks kind of silly. Is there any way to set the cursor for the button & scroll bar widgets? From reading the documentation, it doesn't look like XmNarmCallback, XmNactivate Callback, or XmNdisarmCallback will do this for me. Also, I can't see where there is a resource for a PushButton or ScrollBar widget that sets the cursor. So, any suggestions (other than the obvious "don't use an i-beam ;-)? Any help would be greatly appreciated. Chris Dow IntelliGenetics Software Engineer 700 East El Camino Real icbmnet: 37 22' 39" N, 122 3' 32" W Mountain View, Ca. 94040 dow@presto.ig.com (415) 962-7320
bni@modulex.dk (Bent Nielsen) (01/26/91)
dow@PRESTO.IG.COM (Christopher Dow) writes: --- stuff deleted --- >When the mouse is over the editing area, I set the cursor to be an >i-beam. When it's not I set the cursor to be an arrow. The only >problem is, that I don't get informed when the mouse moves over the >scroll bars or the button, so if it moves from the editing area to the >scroll bars, it stays an i-beam, which looks kind of silly. Is there >any way to set the cursor for the button & scroll bar widgets? From >reading the documentation, it doesn't look like XmNarmCallback, >XmNactivate Callback, or XmNdisarmCallback will do this for me. Also, I >can't see where there is a resource for a PushButton or ScrollBar widget >that sets the cursor. --- stuff deleted --- The way to be informed when the mouse moves over a widget, is to "receive" events for ENTER and LEAVE. The ENTER event is when the mouse enter a widget and LEAVE is when the mouse leave the widget. You can ether add a event handler or a translation to the widget (the scroll bar or the push button). Look in your manual on XtAddEventHandler or about translations. The callbacks for XmNarmCallback and XmNdisarmCallback will only be called when you Press or Release the button on the mouse. -- Bent Nielsen <bni@modulex.dk> A/S MODULEX Phone: +45 44 53 30 11 Lyskaer 15 Telefax: +45 44 53 30 74 DK-2730 Herlev Denmark
tjhorton@vis.toronto.edu ("Timothy J. Horton") (01/27/91)
About how to use different cursors for different areas of a screen... dow@PRESTO.IG.COM (Christopher Dow) writes: >When the mouse is over the editing area, I set the cursor to be an >i-beam. When it's not I set the cursor to be an arrow. The only >problem is, that I don't get informed when the mouse moves over the >scroll bars or the button, so if it moves from the editing area to the >scroll bars, it stays an i-beam, which looks kind of silly. Is there >any way to set the cursor for the button & scroll bar widgets? From >reading the documentation, it doesn't look like XmNarmCallback, >XmNactivate Callback, or XmNdisarmCallback will do this for me. Also, I >can't see where there is a resource for a PushButton or ScrollBar widget >that sets the cursor. Way way down in Xlib, where widgets never go and only windows live, you can specify a cursor for each window. Whenever the cursor is in the window, the cursor pixmap is swapped to the specific window's cursor without any interaction with your program (unless you solicit such interaction, but that's another matter). If you override the cursor for a widget's window, you are doing something that is not strictly proper, but if the widget provides no facilities to set the cursor, you have no other option. (In the case of your widgetless "text window", though, you wouldn't be doing anything improper anyways, seeing as widgets are uninvolved). The code (as near as I remember -- not near books now) is something like #include <X11/cursorfont.h> XDefineCursor(display, window, cursor); Where cursor is something like XC_watch (as defined in cursorfont.h) or something of your own invention. To do this to a widget's window, window can be acquired from a widget by XtWindow(widget), after the widget has been realized (or else the window id is zero, since it has not been created yet!).