_showHidden = show;
}
-naRef FGFileDialog::openFromNasal(const nasal::CallContext& ctx)
-{
- exec();
- return naNil();
-}
-
-naRef FGFileDialog::closeFromNasal(const nasal::CallContext& ctx)
-{
- close();
- return naNil();
-}
-
class NasalCallback : public FGFileDialog::Callback
{
public:
int _gcKeys[2];
};
-naRef FGFileDialog::setCallbackFromNasal(const nasal::CallContext& ctx)
+void FGFileDialog::setCallbackFromNasal(const nasal::CallContext& ctx)
{
// wrap up the naFunc in our callback type
naRef func = ctx.requireArg<naRef>(0);
naRef object = ctx.getArg<naRef>(1, naNil());
setCallback(new NasalCallback(func, object));
- return naNil();
}
typedef boost::shared_ptr<FGFileDialog> FileDialogPtr;
typedef nasal::Ghost<FileDialogPtr> NasalFileDialog;
/**
- * Create new Canvas and get ghost for it.
+ * Create new FGFileDialog and get ghost for it.
*/
static naRef f_createFileDialog(naContext c, naRef me, int argc, naRef* args)
{
.member("show_hidden", &FGFileDialog::showHidden, &FGFileDialog::setShowHidden)
.member("placeholder", &FGFileDialog::getPlaceholder, &FGFileDialog::setPlaceholderName)
.member("pattern", &FGFileDialog::filterPatterns, &FGFileDialog::setFilterPatterns)
- .method<&FGFileDialog::openFromNasal>("open")
- .method<&FGFileDialog::closeFromNasal>("close")
- .method<&FGFileDialog::setCallbackFromNasal>("setCallback");
+ .method("open", &FGFileDialog::exec)
+ .method("close", &FGFileDialog::close)
+ .method("setCallback", &FGFileDialog::setCallbackFromNasal);
nasal::Hash guiModule = nasal::Hash(globals, c).get<nasal::Hash>("gui");
*/
virtual ~FGFileDialog ();
- virtual void exec() = 0;
- virtual void close() = 0;
+ virtual void exec() = 0;
+ virtual void close() = 0;
- class Callback
- {
- public:
- virtual ~Callback() { }
- virtual void onFileDialogDone(FGFileDialog* ins, const SGPath& result) = 0;
- };
+ class Callback
+ {
+ public:
+ virtual ~Callback() { }
+ virtual void onFileDialogDone(FGFileDialog* ins, const SGPath& result) = 0;
+ };
- virtual void setCallback(Callback* aCB);
+ virtual void setCallback(Callback* aCB);
- naRef openFromNasal(const nasal::CallContext& ctx);
- naRef closeFromNasal(const nasal::CallContext& ctx);
- naRef setCallbackFromNasal(const nasal::CallContext& ctx);
+ void setCallbackFromNasal(const nasal::CallContext& ctx);
protected:
FGFileDialog(Usage use);
return NasalElement::create(c, event.getTarget().lock());
}
-// TODO allow directly exposing functions without parameters and return type
-naRef f_eventStopPropagation(sc::Event& event, const nasal::CallContext& ctx)
+void f_eventStopPropagation(sc::Event& event)
{
- if( ctx.argc != 0 )
- naRuntimeError(ctx.c, "Event::stopPropagation no argument expected");
event.stopPropagation();
- return naNil();
}
naRef initNasalCanvas(naRef globals, naContext c, naRef gcSave)
NasalEvent::init("canvas.Event")
.member("type", &sc::Event::getTypeString)
.member("target", &f_eventGetTarget)
- .method_func<&f_eventStopPropagation>("stopPropagation");
+ .method("stopPropagation", &f_eventStopPropagation);
NasalMouseEvent::init("canvas.MouseEvent")
.bases<NasalEvent>()
.member("screenX", &sc::MouseEvent::getScreenX)
.member("_node_ghost", &elementGetNode<sc::Canvas>)
.member("size_x", &sc::Canvas::getSizeX)
.member("size_y", &sc::Canvas::getSizeY)
- .method_func<&f_canvasCreateGroup>("_createGroup")
- .method<&sc::Canvas::addEventListener>("addEventListener");
+ .method("_createGroup", &f_canvasCreateGroup)
+ .method("addEventListener", &sc::Canvas::addEventListener);
NasalElement::init("canvas.Element")
.member("_node_ghost", &elementGetNode<sc::Element>)
- .method<&sc::Element::addEventListener>("addEventListener")
- .method_func<&f_elementGetTransformedBounds>("getTransformedBounds");
+ .method("addEventListener", &sc::Element::addEventListener)
+ .method("getTransformedBounds", &f_elementGetTransformedBounds);
NasalGroup::init("canvas.Group")
.bases<NasalElement>()
- .method_func<&f_groupCreateChild>("_createChild")
- .method_func<&f_groupGetChild>("_getChild")
- .method_func<&f_groupGetElementById>("_getElementById");
+ .method("_createChild", &f_groupCreateChild)
+ .method("_getChild", &f_groupGetChild)
+ .method("_getElementById", &f_groupGetElementById);
NasalText::init("canvas.Text")
.bases<NasalElement>()
- .method_func<&f_textGetNearestCursor>("getNearestCursor");
+ .method("getNearestCursor", &f_textGetNearestCursor);
nasal::Hash globals_module(globals, c),
canvas_module = globals_module.createHash("canvas");