Instead of defining the geometry for the sphere using the mouse, the user may want to define the center point of the sphere numerically, by typing x, y and z coordinates through the numeric interface.
The sphnum.c source file implements a gadget that will be shown in the measuring system window when the sphere interactor is active.
These numeric gadgets are interactor gadgets similar to the sphctrl.c gadget, that allows the user to control creation options and are derived from the very same base class 'inc/real/iagad/r3iagad.h'.
Numeric gadgets should handle their gadget events a bit differently, however. When the user enters numeric mode, the interactor should stop handling R3IAM_MOVE events so that accidental mouse moves will not override carefully entered numerical coordinates.
Therefore, numeric gadgets should catch the event that triggered the callback methods:
static void *mynumgad_radius(R3CLASS *cl, R3OBJ *obj, R3INT event, R3VECTGVAL *v) { R3IDATA *self = R3CL_IADDR(cl, obj); if (event == R3OGM_GADGETDOWN) { /* user has enabled our numeric gadget, tell interactor that * we have entered numeric mode */ int ui; R3GetAttrs(self->interactor, R3IAA_UserInput, &ui, R3TAG_END); if (!ui) R3SetAttrs(self->interactor, R3IAA_UserInput, TRUE, R3TAG_END); } if (event == R3OGM_GADGETUP) { /* user has entered new value, exit numeric mode */ R3MAC_SETATTR(app, "R3CurrentInteractor", self->interactor, SPHIA_Radius, msg, R3MCTP_FLOAT); R3DoA(self->interactor, R3IAM_ACCEPTUSERINPUT, NULL); if (self->focus_set) { R3DoA(self->radius, R3WGM_RESTOREFOCUS, NULL); self->focus_set = FALSE; } } else if (event == R3OGM_ACTIVE) self->has_focus = TRUE; else if (event == R3OGM_INACTIVE) self->has_focus = FALSE; return (void *)TRUE; }
To plug the gadget into the numeric interface, call:
#include <real/widget/r3sbar.h> if(R3ClassFind(R3CLID_STATUSBAR)) R3DoClassA2(R3CLID_STATUSBAR, R3IBCM_INSTALLGADGET, (void *)R3CLID_SDKSPHEREINTERACTOR, (void *)R3CLID_SPHERENUMERICGADGET);