void OpenUserDataRec::EventProcCBEventMouseDown(NavCBRecPtr callBackParms) { EventRecord *evt = callBackParms->eventData.eventDataParms.event; Point where = evt->where; QDGlobalToLocalPoint(GetWindowPort(callBackParms->window), &where); ControlRef whichControl = FindControlUnderMouse(where, callBackParms->window, NULL); if (whichControl != NULL) { ControlKind theKind; GetControlKind(whichControl, &theKind); // Moving the focus if we clicked in an focusable control if ((theKind.kind == kControlKindEditUnicodeText) || (theKind.kind == kControlKindEditText) || (theKind.kind == kControlKindDataBrowser) || (theKind.kind == kControlKindListBox)) { ControlRef currentlyFocusedControl; GetKeyboardFocus(callBackParms->window, ¤tlyFocusedControl); if (currentlyFocusedControl != whichControl) SetKeyboardFocus(callBackParms->window, whichControl, kControlFocusNextPart); } HandleControlClick(whichControl, where, evt->modifiers, NULL); } }
static void MacScaleEventProc( ClientData clientData, /* Information about window. */ XEvent *eventPtr) /* Information about event. */ { MacScale *macScalePtr = (MacScale *) clientData; Point where; Rect bounds; int part; CGrafPtr destPort, savePort; Boolean portChanged; #ifdef TK_MAC_DEBUG_SCALE fprintf(stderr,"MacScaleEventProc\n" ); #endif /* * To call Macintosh control routines we must have the port * set to the window containing the control. We will then test * which part of the control was hit and act accordingly. */ destPort = TkMacOSXGetDrawablePort(Tk_WindowId(macScalePtr->info.tkwin)); portChanged = QDSwapPort(destPort, &savePort); TkMacOSXSetUpClippingRgn(Tk_WindowId(macScalePtr->info.tkwin)); TkMacOSXWinBounds((TkWindow *) macScalePtr->info.tkwin, &bounds); where.h = eventPtr->xbutton.x + bounds.left; where.v = eventPtr->xbutton.y + bounds.top; #ifdef TK_MAC_DEBUG_SCALE TkMacOSXDbgMsg("calling TestControl"); #endif part = TestControl(macScalePtr->scaleHandle, where); if (part == 0) { return; } TkMacOSXTrackingLoop(1); part = HandleControlClick(macScalePtr->scaleHandle, where, TkMacOSXModifierState(), scaleActionProc); TkMacOSXTrackingLoop(0); /* * Update the value for the widget. */ macScalePtr->info.value = GetControlValue(macScalePtr->scaleHandle); /* TkScaleSetValue(&macScalePtr->info, macScalePtr->info.value, 1, 0); */ /* * The HandleControlClick call will "eat" the ButtonUp event. We now * generate a ButtonUp event so Tk will unset implicit grabs etc. */ TkGenerateButtonEventForXPointer(Tk_WindowId(macScalePtr->info.tkwin)); if (portChanged) { QDSwapPort(savePort, NULL); } }
void _GuiMacCheckButton_handleClick (GuiObject widget, EventRecord *macEvent) { iam_checkbutton; _GuiMac_clipOnParent (widget); bool clicked = HandleControlClick (widget -> nat.control.handle, macEvent -> where, macEvent -> modifiers, NULL); GuiMac_clipOff (); if (clicked) { if (my d_valueChangedCallback != NULL) { struct structGuiCheckButtonEvent event = { me }; my d_valueChangedCallback (my d_valueChangedBoss, & event); } } }
static void HandleCustomMouseDown(NavCBRecPtr callBackParms, CustomData *data) { EventRecord *evt = callBackParms->eventData.eventDataParms.event; Point where = evt->where; GlobalToLocal(&where); ControlRef control = FindControlUnderMouse(where, callBackParms->window, NULL); if (control != NULL) { HandleControlClick(control, where, evt->modifiers, (ControlActionUPP)-1L); NavCustomControl(callBackParms->context, kNavCtlBrowserRedraw, NULL); } }
void _GuiMacButton_handleClick (GuiObject widget, EventRecord *macEvent) { iam_button; _GuiMac_clipOnParent (widget); bool pushed = HandleControlClick (widget -> nat.control.handle, macEvent -> where, macEvent -> modifiers, NULL); GuiMac_clipOff (); if (pushed && my activateCallback != NULL) { struct structGuiButtonEvent event = { widget, 0 }; //enum { cmdKey = 256, shiftKey = 512, optionKey = 2048, controlKey = 4096 }; Melder_assert (macEvent -> what == mouseDown); event. shiftKeyPressed = (macEvent -> modifiers & shiftKey) != 0; event. commandKeyPressed = (macEvent -> modifiers & cmdKey) != 0; event. optionKeyPressed = (macEvent -> modifiers & optionKey) != 0; event. extraControlKeyPressed = (macEvent -> modifiers & controlKey) != 0; try { my activateCallback (my activateBoss, & event); } catch (MelderError) { Melder_error_ ("Your click on button \"", widget -> name, "\" was not completely handled."); Melder_flushError (NULL); } } }
void _GuiMacRadioButton_handleClick (GuiObject widget, EventRecord *macEvent) { iam_radiobutton; _GuiMac_clipOnParent (widget); bool clicked = HandleControlClick (widget -> nat.control.handle, macEvent -> where, macEvent -> modifiers, NULL); GuiMac_clipOff (); if (clicked) { /* * Deselect the sister buttons. */ for (GuiRadioButton sibling = my d_previous; sibling != NULL; sibling = sibling -> d_previous) { SetControlValue (sibling -> d_widget -> nat.control.handle, 0); } for (GuiRadioButton sibling = my d_next; sibling != NULL; sibling = sibling -> d_next) { SetControlValue (sibling -> d_widget -> nat.control.handle, 0); } if (my d_valueChangedCallback != NULL) { struct structGuiRadioButtonEvent event = { me }; event. position = _GuiRadioButton_getPosition (me); my d_valueChangedCallback (my d_valueChangedBoss, & event); } } }
static void HandleCustomMouseDown(NavCBRecPtr callBackParms, CustomData *data) { EventRecord *evt = callBackParms->eventData.eventDataParms.event; Point where = evt->where; GlobalToLocal(&where); ControlRef control = FindControlUnderMouse(where, callBackParms->window, NULL); if (control != NULL) { ControlID cid; GetControlID(control, &cid); HandleControlClick(control, where, evt->modifiers, (ControlActionUPP)-1L); if (cid.signature == kCustom) { switch (cid.id) { case kChoice: { MenuRef menu; UInt32 v; menu = GetControlPopupMenuRef(control); v = GetControl32BitValue(control) - 1; const size_t numFilters = data->extensions.GetCount(); if (v < numFilters) { data->currentfilter = v; if (data->saveMode) { int i = data->currentfilter; wxString extension = data->extensions[i].AfterLast('.') ; extension.MakeLower() ; wxString sfilename ; wxMacCFStringHolder cfString(NavDialogGetSaveFileName(callBackParms->context), false); sfilename = cfString.AsString() ; #if 0 int pos = sfilename.Find('.', true) ; if (pos != wxNOT_FOUND) { sfilename = sfilename.Left(pos + 1) + extension; cfString.Assign(sfilename, wxFONTENCODING_DEFAULT); NavDialogSetSaveFileName(callBackParms->context, cfString); } #endif } NavCustomControl(callBackParms->context, kNavCtlBrowserRedraw, NULL); } break; } case kButton: { data->me->ClickButton(GetControl32BitValue(data->choice) - 1); break; } } } } }