void ClientObject::initInternalCallbacks() { if(!futureValueCallback) { futureValueCallback = new FutureValueCallback(view); CppBoundClass::Callback* callback = NewCallback<FutureValueCallback, const CppArgumentList&, CppVariant*>(futureValueCallback, &FutureValueCallback::handleCallback); BindCallback("____futureValue", callback); } if(!checkKeyboardFocusCallback) { checkKeyboardFocusCallback = new CheckKeyboardFocusCallback(view); CppBoundClass::Callback* callback = NewCallback<CheckKeyboardFocusCallback, const CppArgumentList&, CppVariant*>(checkKeyboardFocusCallback, &CheckKeyboardFocusCallback::handleCallback); BindCallback("____checkKeyboardFocus", callback); } }
void NervColumnLayout::AddChild(std::unique_ptr<NervWindow> in_child){ int y = 0; if (children.size() != 0){ y = children.back()->GetBottomRightPoint().y; } children.push_back(std::move(in_child)); auto new_child = children.back().get(); new_child->SetPosition(NervPoint{ 0, y }); new_child->SetParent(*this); NervSize sz = children.back()->GetSize(); sz.x = size.x; new_child->SetSize(sz); new_child->Show(); new_child->BindCallback(NervEvent::LostKeyboardFocus, std::make_unique<NervCallback>([this](void* arg){ PerformCallback(NervEvent::LostKeyboardFocus,arg); })); new_child->BindCallback(NervEvent::SizeLimitChanged, std::make_unique<NervCallback>([this](void*){ OnSizeLimitChanged(); })); new_child->BindCallback(NervEvent::SizeChanged, std::make_unique<NervCallback>([this](void*){ OnSizeChanged(); })); resize_manager.LockHeight(y+sz.y); }
void ClientObject::setCallback(const std::string& name) { if(clientCallbacks.find(name) == clientCallbacks.end()) { NamedCallback* namedCallback = new NamedCallback(name, view); clientCallbacks[name] = namedCallback; CppBoundClass::Callback* callback = NewCallback<NamedCallback, const CppArgumentList&, CppVariant*>(namedCallback, &NamedCallback::handleCallback); BindCallback(name, callback); } }