home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!ogicse!amb4.ese.ogi.edu!pturner
- From: pturner@amb4.ese.ogi.edu (Paul J Turner)
- Newsgroups: comp.windows.x.motif
- Subject: Need help using PushButton as ToggleButton
- Keywords: PushButton, Arm, Disarm, ToggleButton
- Message-ID: <41238@ogicse.ogi.edu>
- Date: 12 Aug 92 15:41:42 GMT
- Article-I.D.: ogicse.41238
- Sender: news@ogicse.ogi.edu
- Followup-To: pturner@amb4.ese.ogi.edu
- Distribution: usa
- Organization: Center for Coastal and Land-Margin Research
- Lines: 61
- Originator: pturner@amb4.ese.ogi.edu
-
- Ideally, I'd like to use a ToggleButton with no label and
- a Pixmap of my choosing for the toggle - but I wasn't able to
- to do this. This would be the ideal solution - what follows is
- something that almost works.
-
- I'm trying to use PushButtons with Pixmaps as toggle buttons
- using arm/disarm to indicate the state of the associated boolean
- variable. Things work fine provided the initial state on startup is
- False (button is in a disarmed state). The problem is initializing
- the button to an armed state - the button appears depressed as long
- as the pointer does not traverse the PushButton. When the pointer
- does cross the PushButton, it becomes disarmed when the pointer leaves
- the border of the PushButton's Pixmap. Crossing the PushButton again
- will cause the button to display as armed, but only as long as the
- pointer is in the borders of the Pixmap. Clicking on the PushButton
- a couple of times straightens it out, so the correct state is displayed
- regardless of the position of the pointer.
-
- The button is created as follows, set to an armed state, parent is
- a RowColumn:
-
- bt = XtVaCreateManagedWidget("golly", xmPushButtonWidgetClass, rc,
- XmNlabelType, XmPIXMAP,
- XmNlabelPixmap, gollypm,
- NULL);
- XtAddCallback(bt, XmNactivateCallback, toggle_golly_proc, GOLLY_VAL);
- /*
- * this button's initial state is True, so display as armed
- */
- XtCallActionProc(bt, "Arm", NULL, NULL, 0);
- ^^^^ I think the problem is here,
- should be an event. But how
- is it defined?
-
- While the program is running, the button is toggled using:
-
- void toggle_golly_proc(w, cd, cbs)
- Widget w;
- int cd;
- XmAnyCallbackStruct *cbs;
- {
- switch (cd) {
- case GOLLY_VAL:
- if (do_golly) {
- XtCallActionProc(w, "Disarm", cbs->event, NULL, 0);
- do_golly = 0;
- } else {
- XtCallActionProc(w, "Arm", cbs->event, NULL, 0);
- do_golly = 1;
- }
- }
- }
-
- This works just fine.
-
- Any clues would be appreciated.
-
- Thanks,
-
- Paul J Turner
- pturner@amb4.ese.ogi.edu
-