From a8ecc81a8b29a07bb554dcc24c0d54c950d219d5 Mon Sep 17 00:00:00 2001 From: Ian Macphail Date: Tue, 16 Apr 2013 13:31:20 +0100 Subject: [PATCH] add global variable revMessageBoxLastObject implement new global variable revMessageBoxLastObject available within the development environment --- engine/src/lextable.cpp | 1 + engine/src/mode_development.cpp | 65 +++++++++++++++++++++++++++++++++ engine/src/parsedef.h | 1 + engine/src/property.cpp | 1 + 4 files changed, 68 insertions(+) diff --git a/engine/src/lextable.cpp b/engine/src/lextable.cpp index d7ee743e947..0451e1f261b 100644 --- a/engine/src/lextable.cpp +++ b/engine/src/lextable.cpp @@ -1293,6 +1293,7 @@ LT factor_table[] = #ifdef MODE_DEVELOPMENT {"revlicenseinfo", TT_PROPERTY, P_REV_LICENSE_INFO}, {"revlicenselimits",TT_PROPERTY,P_REV_LICENSE_LIMITS}, + {"revmessageboxlastobject", TT_PROPERTY, P_REV_MESSAGE_BOX_LAST_OBJECT}, {"revmessageboxredirect", TT_PROPERTY, P_REV_MESSAGE_BOX_REDIRECT}, #ifdef FEATURE_PROPERTY_LISTENER // MM-2012-09-05: [[ Property Listener ]] Returns the list of all active object property listeners diff --git a/engine/src/mode_development.cpp b/engine/src/mode_development.cpp index e032f649a33..72d50c2d006 100644 --- a/engine/src/mode_development.cpp +++ b/engine/src/mode_development.cpp @@ -57,6 +57,7 @@ along with LiveCode. If not see . */ #include "license.h" #include "mode.h" #include "revbuild.h" +#include "parentscript.h" #if defined(_WINDOWS_DESKTOP) #include "w32prefix.h" @@ -97,6 +98,12 @@ Boolean MCenvironmentactive = False; MCObject *MCmessageboxredirect = NULL; +// IM-2013-04-16: [[ BZ 10836 ]] Provide reference to the last "put" source +// as a global property, the "revMessageBoxLastObject" +MCObjectHandle *MCmessageboxlastobject = nil; +MCNameRef MCmessageboxlasthandler = nil; +uint32_t MCmessageboxlastline = 0; + Boolean MCcrashreportverbose = False; char *MCcrashreportfilename = NULL; @@ -952,6 +959,22 @@ Exec_stat MCProperty::mode_eval(MCExecPoint& ep) { switch(which) { + case P_REV_MESSAGE_BOX_LAST_OBJECT: + if (MCmessageboxlastobject != NULL && MCmessageboxlastobject->Exists()) + { + MCmessageboxlastobject->Get()->names(P_LONG_ID, ep, 0); + ep.concatnameref(MCmessageboxlasthandler, EC_COMMA, false); + ep.concatuint(MCmessageboxlastline, EC_COMMA, false); + if (MCmessageboxlastobject->Get()->getparentscript() != nil) + { + MCExecPoint ep2; + MCmessageboxlastobject->Get()->getparentscript()->GetObject()->names(P_LONG_ID, ep2, 0); + ep.concatmcstring(ep2.getsvalue(), EC_COMMA, false); + } + } + else + ep.clear(); + break; case P_REV_MESSAGE_BOX_REDIRECT: if (MCmessageboxredirect != NULL) MCmessageboxredirect -> names(P_LONG_ID, ep, 0); @@ -1119,6 +1142,48 @@ bool MCModeShouldCheckCantStandalone(void) 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) diff --git a/engine/src/parsedef.h b/engine/src/parsedef.h index fb6db0e9f19..ed1c1c83fe6 100644 --- a/engine/src/parsedef.h +++ b/engine/src/parsedef.h @@ -1517,6 +1517,7 @@ enum Properties { P_REV_LICENSE_LIMITS, // DEVELOPMENT only P_REV_CRASH_REPORT_SETTINGS, // DEVELOPMENT only P_REV_AVAILABLE_HANDLERS, // DEVELOPMENT only + P_REV_MESSAGE_BOX_LAST_OBJECT, // DEVELOPMENT only P_REV_MESSAGE_BOX_REDIRECT, // DEVELOPMENT only P_REV_LICENSE_INFO, // DEVELOPMENT only diff --git a/engine/src/property.cpp b/engine/src/property.cpp index c4d699ce7c8..323e51be81e 100644 --- a/engine/src/property.cpp +++ b/engine/src/property.cpp @@ -482,6 +482,7 @@ Parse_stat MCProperty::parse(MCScriptPoint &sp, Boolean the) // MM-2011-07-14: Add support for listing avaiable network interfaces case P_NETWORK_INTERFACES: + case P_REV_MESSAGE_BOX_LAST_OBJECT: // DEVELOPMENT only case P_REV_MESSAGE_BOX_REDIRECT: // DEVELOPMENT only case P_REV_LICENSE_LIMITS: // DEVELOPMENT only