From: Thomas Geymayer Date: Sun, 16 Dec 2012 23:32:02 +0000 (+0100) Subject: Expose canvas Text::getNearestCursor to Nasal as replacement for old property based... X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=e844383988d13c9717bf9c126e153aeb30fa04ae;p=flightgear.git Expose canvas Text::getNearestCursor to Nasal as replacement for old property based method --- diff --git a/src/Scripting/NasalCanvas.cxx b/src/Scripting/NasalCanvas.cxx index f682213b7..f349dadb5 100644 --- a/src/Scripting/NasalCanvas.cxx +++ b/src/Scripting/NasalCanvas.cxx @@ -33,6 +33,7 @@ #include #include +#include #include #include @@ -55,6 +56,7 @@ typedef nasal::Ghost NasalMouseEvent; typedef nasal::Ghost NasalCanvas; typedef nasal::Ghost NasalElement; typedef nasal::Ghost NasalGroup; +typedef nasal::Ghost NasalText; SGPropertyNode* from_nasal_helper(naContext c, naRef ref, SGPropertyNode**) { @@ -162,6 +164,15 @@ naRef f_groupGetElementById(sc::Group& group, const nasal::CallContext& ctx) ); } +naRef f_textGetNearestCursor(sc::Text& text, const nasal::CallContext& ctx) +{ + return nasal::to_nasal + ( + ctx.c, + text.getNearestCursor( ctx.requireArg(0) ) + ); +} + naRef f_eventGetTarget(naContext c, sc::Event& event) { return NasalElement::create(c, event.getTarget().lock()); @@ -206,6 +217,9 @@ naRef initNasalCanvas(naRef globals, naContext c, naRef gcSave) .method_func<&f_groupCreateChild>("_createChild") .method_func<&f_groupGetChild>("_getChild") .method_func<&f_groupGetElementById>("_getElementById"); + NasalText::init("canvas.Text") + .bases() + .method_func<&f_textGetNearestCursor>("getNearestCursor"); nasal::Hash globals_module(globals, c), canvas_module = globals_module.createHash("canvas");