From 7a47afc89cd0aec9eeb5eeaaa256ecf890036432 Mon Sep 17 00:00:00 2001 From: "Andrew A. de Laix" Date: Wed, 7 Sep 2011 14:36:39 -0500 Subject: add getInfo command to get state information about a ui element --- indra/newview/llwindowlistener.cpp | 30 ++++++++++++++++++++++++++++++ indra/newview/llwindowlistener.h | 1 + 2 files changed, 31 insertions(+) (limited to 'indra/newview') diff --git a/indra/newview/llwindowlistener.cpp b/indra/newview/llwindowlistener.cpp index 05cb798732..eb44a702a4 100644 --- a/indra/newview/llwindowlistener.cpp +++ b/indra/newview/llwindowlistener.cpp @@ -82,6 +82,7 @@ LLWindowListener::LLWindowListener(LLViewerWindow *window, const KeyboardGetter& "Optional [\"reply\"] requests a reply event on the named LLEventPump.\n" "reply[\"error\"] isUndefined (None) on success, else an explanatory message.\n"; + add("getInfo", "Get information about the ui element specified by [\"path\"]", &LLWindowListener::getInfo); add("keyDown", keySomething + "keypress event.\n" + keyExplain + mask, &LLWindowListener::keyDown); @@ -246,6 +247,35 @@ KEY getKEY(const LLSD& event) } // namespace +void LLWindowListener::getInfo(LLSD const & evt) +{ + Response response(LLSD(), evt); + + if (evt.has("path")) + { + std::string path(evt["path"]); + LLView * target_view = + LLUI::resolvePath(gViewerWindow->getRootView(), path); + if (target_view != 0) + { + insertViewInformation(response, target_view); + LLRect rect(target_view->calcScreenRect()); + response["rect"] = LLSDMap("left", rect.mLeft)("top", rect.mTop) + ("right", rect.mRight)("bottom", rect.mBottom); + } + else + { + response.error(STRINGIZE(evt["op"].asString() << " request " + "specified invalid \"path\": '" << path << "'")); + } + } + else + { + response.error( + STRINGIZE(evt["op"].asString() << "request did not provide a path" )); + } +} + void LLWindowListener::keyDown(LLSD const & evt) { Response response(LLSD(), evt); diff --git a/indra/newview/llwindowlistener.h b/indra/newview/llwindowlistener.h index 26adff35ff..29c3575258 100644 --- a/indra/newview/llwindowlistener.h +++ b/indra/newview/llwindowlistener.h @@ -39,6 +39,7 @@ public: typedef boost::function KeyboardGetter; LLWindowListener(LLViewerWindow * window, const KeyboardGetter& kbgetter); + void getInfo(LLSD const & evt); void keyDown(LLSD const & evt); void keyUp(LLSD const & evt); void mouseDown(LLSD const & evt); -- cgit v1.2.3