return false;
}
- // FIXME - make x,y available to the binding
- fireBindingList(_hover);
+ SGPropertyNode_ptr params(new SGPropertyNode);
+ params->setDoubleValue("x", windowPos.x());
+ params->setDoubleValue("y", windowPos.y());
+ fireBindingList(_hover, params.ptr());
return true;
}
private:
return false;
}
- // FIXME - make x,y available to the binding
- fireBindingList(_hover);
+ SGPropertyNode_ptr params(new SGPropertyNode);
+ params->setDoubleValue("x", windowPos.x());
+ params->setDoubleValue("y", windowPos.y());
+ fireBindingList(_hover, params.ptr());
return true;
}
private:
#include <simgear/compiler.h>
#include "SGBinding.hxx"
+#include <simgear/props/props_io.hxx>
#include <simgear/structure/exception.hxx>
SGBinding::SGBinding()
}
void
-SGBinding::fire () const
+SGBinding::fire() const
{
if (test()) {
- if (_command == 0)
- _command = SGCommandMgr::instance()->getCommand(_command_name);
- if (_command == 0) {
- SG_LOG(SG_INPUT, SG_WARN, "No command attached to binding");
- } else
- {
- try {
- if (!(*_command)(_arg)) {
- SG_LOG(SG_INPUT, SG_ALERT, "Failed to execute command "
- << _command_name);
- }
- } catch (sg_exception& e) {
- SG_LOG(SG_GENERAL, SG_ALERT, "command '" << _command_name << "' failed with exception\n"
- << "\tmessage:" << e.getMessage() << " (from " << e.getOrigin() << ")");
- }
+ innerFire();
+ }
+}
+
+void
+SGBinding::innerFire () const
+{
+ if (_command == 0)
+ _command = SGCommandMgr::instance()->getCommand(_command_name);
+ if (_command == 0) {
+ SG_LOG(SG_INPUT, SG_WARN, "No command attached to binding:" << _command_name);
+ } else {
+ try {
+ if (!(*_command)(_arg)) {
+ SG_LOG(SG_INPUT, SG_ALERT, "Failed to execute command "
+ << _command_name);
+ }
+ } catch (sg_exception& e) {
+ SG_LOG(SG_GENERAL, SG_ALERT, "command '" << _command_name << "' failed with exception\n"
+ << "\tmessage:" << e.getMessage() << " (from " << e.getOrigin() << ")");
+ }
+ }
+}
+
+void
+SGBinding::fire (SGPropertyNode* params) const
+{
+ if (test()) {
+ if (params != NULL) {
+ copyProperties(params, _arg);
}
+
+ innerFire();
}
}
{
if (test()) {
_arg->setDoubleValue("offset", offset/max);
- fire();
+ innerFire();
}
}
if (_setting == 0) // save the setting node for efficiency
_setting = _arg->getChild("setting", 0, true);
_setting->setDoubleValue(setting);
- fire();
+ innerFire();
}
}
-void fireBindingList(const SGBindingList& aBindings)
+void fireBindingList(const SGBindingList& aBindings, SGPropertyNode* params)
{
BOOST_FOREACH(SGBinding_ptr b, aBindings) {
- b->fire();
+ b->fire(params);
}
}
*/
void fire (double setting) const;
-
+ /**
+ * Fire a binding with a number of additional parameters
+ *
+ * The children of params will be merged with the fixed arguments.
+ */
+ void fire (SGPropertyNode* params) const;
+
private:
+ void innerFire() const;
// just to be safe.
SGBinding (const SGBinding &binding);
* fire every binding in a list, in sequence
*/
-void fireBindingList(const SGBindingList& aBindings);
+void fireBindingList(const SGBindingList& aBindings, SGPropertyNode* params = NULL);
/**
* fire every binding in a list with a setting value