Exec_stat MCDoMenu::exec(MCExecPoint &ep) { if (source->eval(ep) != ES_NORMAL) { MCeerror->add (EE_DOMENU_BADEXP, line, pos); return ES_ERROR; } const char *dstring = lookup(ep.getsvalue()); if (dstring == NULL) { char *tptr = ep.getsvalue().clone(); ep.setstringf("doMenu \"%s\" not implemented", tptr); delete tptr; MCresult->sets(ep.getsvalue()); } else { ep.getobj()->domess(dstring); } return ES_NORMAL; }
bool MCModeHandleMessageBoxChanged(MCExecPoint& ep) { // IM-2013-04-16: [[ BZ 10836 ]] update revMessageBoxLastObject // if the source of the change is not within the message box MCObject *t_msg_box = nil; if (MCmessageboxredirect != nil) t_msg_box = MCmessageboxredirect; else { if (MCmbstackptr == nil) MCmbstackptr = MCdispatcher->findstackname(MCmessagenamestring); t_msg_box = MCmbstackptr; } MCObject *t_src_object = nil; if (ep.getobj() != nil) t_src_object = ep.getobj(); bool t_in_msg_box = false; MCObject *t_obj_ptr = t_src_object; while (t_obj_ptr != nil) { if (t_obj_ptr == t_msg_box) { t_in_msg_box = true; break; } t_obj_ptr = t_obj_ptr->getparent(); } if (!t_in_msg_box) { if (MCmessageboxlastobject != nil) MCmessageboxlastobject->Release(); MCmessageboxlastobject = t_src_object->gethandle(); MCNameDelete(MCmessageboxlasthandler); MCmessageboxlasthandler = nil; MCNameClone(ep.gethandler()->getname(), MCmessageboxlasthandler); MCmessageboxlastline = ep.getline(); } if (MCmessageboxredirect != NULL) { if (MCmessageboxredirect -> gettype() == CT_FIELD) { MCStack *t_msg_stack; t_msg_stack = MCmessageboxredirect -> getstack(); Window_mode newmode = t_msg_stack -> userlevel() == 0 ? WM_MODELESS : (Window_mode)(t_msg_stack -> userlevel() + WM_TOP_LEVEL_LOCKED); // MW-2011-07-05: [[ Bug 9608 ]] The 'ep' that is passed through to us does // not necessarily have an attached object any more. Given that the 'rel' // parameter of the open stack call is unused, computing it from that // context is redundent. if (t_msg_stack -> getmode() != newmode) t_msg_stack -> openrect(t_msg_stack -> getrect(), newmode, NULL, WP_DEFAULT, OP_NONE); else t_msg_stack -> raise(); ((MCField *)MCmessageboxredirect) -> settext(0, ep . getsvalue(), False); } else { MCAutoNameRef t_msg_changed; /* UNCHECKED */ t_msg_changed . CreateWithCString("msgchanged"); bool t_added; if (MCnexecutioncontexts < MAX_CONTEXTS && ep . getobj() != nil) { MCexecutioncontexts[MCnexecutioncontexts++] = &ep; t_added = true; } MCmessageboxredirect -> message(t_msg_changed); if (t_added) MCnexecutioncontexts--; } return true; } return false; }
Exec_stat MCComref::exec(MCExecPoint &ep) { if (MCscreen->abortkey()) { MCeerror->add(EE_HANDLER_ABORT, line, pos); return ES_ERROR; } if (!resolved) { // MW-2008-01-28: [[ Inherited parentScripts ]] // If we are in parentScript context, then the object we search for // private handlers in is the parentScript's object, rather than the // ep's. MCParentScriptUse *t_parentscript; t_parentscript = ep . getparentscript(); MCObject *t_object; if (t_parentscript == NULL) t_object = ep . getobj(); else t_object = t_parentscript -> GetParent() -> GetObject(); // MW-2008-10-28: [[ ParentScripts ]] Private handlers are resolved // relative to the object containing the handler we are executing. MCHandler *t_resolved_handler; t_resolved_handler = t_object -> findhandler(HT_MESSAGE, name); if (t_resolved_handler != NULL && t_resolved_handler -> isprivate()) handler = t_resolved_handler; resolved = true; } Exec_stat stat; MCParameter *tptr = params; while (tptr != NULL) { MCVariable* t_var; t_var = tptr -> evalvar(ep); if (t_var == NULL) { tptr -> clear_argument(); while ((stat = tptr->eval(ep)) != ES_NORMAL && (MCtrace || MCnbreakpoints) && !MCtrylock && !MClockerrors) MCB_error(ep, line, pos, EE_STATEMENT_BADPARAM); if (stat != ES_NORMAL) { MCeerror->add(EE_STATEMENT_BADPARAM, line, pos); return ES_ERROR; } tptr->set_argument(ep); } else tptr->set_argument_var(t_var); tptr = tptr->getnext(); } MCObject *p = ep.getobj(); MCExecPoint *oldep = MCEPptr; MCEPptr = &ep; stat = ES_NOT_HANDLED; Boolean added = False; if (MCnexecutioncontexts < MAX_CONTEXTS) { ep.setline(line); MCexecutioncontexts[MCnexecutioncontexts++] = &ep; added = True; } if (handler != nil) { // MW-2008-10-28: [[ ParentScripts ]] If we are in the context of a // parent, then use a special method. if (ep . getparentscript() == NULL) stat = p -> exechandler(handler, params); else stat = p -> execparenthandler(handler, params, ep . getparentscript()); switch(stat) { case ES_ERROR: case ES_PASS: MCeerror->add(EE_STATEMENT_BADCOMMAND, line, pos, handler -> getname()); if (MCerrorptr == NULL) MCerrorptr = p; stat = ES_ERROR; break; case ES_EXIT_HANDLER: stat = ES_NORMAL; break; default: break; } } else { stat = MCU_dofrontscripts(HT_MESSAGE, name, params); Boolean olddynamic = MCdynamicpath; MCdynamicpath = MCdynamiccard != NULL; if (stat == ES_PASS || stat == ES_NOT_HANDLED) switch (stat = p->handle(HT_MESSAGE, name, params, p)) { case ES_ERROR: case ES_NOT_FOUND: case ES_NOT_HANDLED: case ES_PASS: MCeerror->add(EE_STATEMENT_BADCOMMAND, line, pos, name); stat = ES_ERROR; break; case ES_EXIT_HANDLER: stat = ES_NORMAL; break; default: break; } MCdynamicpath = olddynamic; } MCEPptr = oldep; if (added) MCnexecutioncontexts--; return stat; }