hafer (Udo Hafermann) (07/28/89)
How do I change the cursor of a Command (or other) Widget? WidgetSet (w, XtNcursor, cursor, ...) doesn't seem to work. Is it possible at all?
converse@EXPO.LCS.MIT.EDU (Donna Converse) (07/30/89)
> How do I change the cursor of a Command (or other) Widget? In order to allow the user to override your choice of cursor, specify the cursor in an application defaults file. For example, to set all command widgets in the application class of Demo to use the gumby cursor, put this in your app defaults file: Demo*Command.cursor: gumby If you want to set the cursor in your code, you will insure that the particular cursor you chose can never be changed by a user. For an individual widget, such as a Command widget, the cursor can be set at creation time or later, using the resource XtNcursor. Here's some excerpted code as an example: #include <X11/cursorfont.h> cursor = XCreateFontCursor(XtDisplay(widget), XC_gumby); XtSetArg(args[0], XtNcursor, cursor); XtCreateManagedWidget("button", commandWidgetClass, parent, args, ONE); or, after the widget has been realized ... cursor = XCreateFontCursor(XtDisplay(widget), XC_gumby); XtSetArg(args[0], XtNcursor, cursor); XtSetValues(button, args, ONE); In case you want to set the cursor of a popup window, use the Xlib function XDefineCursor after the popup has been realized. > WidgetSet (w, XtNcursor, cursor, ...) doesn't seem to work. I don't know where this interface is defined, or what it is. Donna
kit@EXPO.LCS.MIT.EDU (Chris D. Peterson) (07/31/89)
Donna's reply on the semantics of setting the cursor is correct. It should be noted, however, that the widget must support the XtNcursor resource (or something like it) in order for the XtSetValues call to work. You should check the documentation on the widget set that you are using to see if the widget that you are interested in has this particular resource. If the widget does not have a cursor resource you can always use XDefineCursor(), as Donna mentioned, but be sure that your widget is realized or you will get an X protocol error. Chris D. Peterson MIT X Consortium Net: kit@expo.lcs.mit.edu Phone: (617) 253 - 9608 Address: MIT - Room NE43-213