all events
This commit is contained in:
parent
f40afe684a
commit
a9667d38fd
7 changed files with 1061 additions and 5 deletions
|
|
@ -24,24 +24,214 @@ import std;
|
|||
export namespace Crafter::CppDOM::Bindings {
|
||||
int clickHandlerMaxId = 0;
|
||||
std::unordered_map<int, std::function<void(void)>>* clickHandlers = new std::unordered_map<int, std::function<void(void)>>();
|
||||
|
||||
int mouseOverHandlerMaxId = 0;
|
||||
std::unordered_map<int, std::function<void(void)>>* mouseOverHandlers = new std::unordered_map<int, std::function<void(void)>>();
|
||||
|
||||
int mouseOutHandlerMaxId = 0;
|
||||
std::unordered_map<int, std::function<void(void)>>* mouseOutHandlers = new std::unordered_map<int, std::function<void(void)>>();
|
||||
|
||||
int mouseMoveHandlerMaxId = 0;
|
||||
std::unordered_map<int, std::function<void(void)>>* mouseMoveHandlers = new std::unordered_map<int, std::function<void(void)>>();
|
||||
|
||||
int focusHandlerMaxId = 0;
|
||||
std::unordered_map<int, std::function<void(void)>>* focusHandlers = new std::unordered_map<int, std::function<void(void)>>();
|
||||
|
||||
int blurHandlerMaxId = 0;
|
||||
std::unordered_map<int, std::function<void(void)>>* blurHandlers = new std::unordered_map<int, std::function<void(void)>>();
|
||||
|
||||
int keyDownHandlerMaxId = 0;
|
||||
std::unordered_map<int, std::function<void(void)>>* keyDownHandlers = new std::unordered_map<int, std::function<void(void)>>();
|
||||
|
||||
int keyUpHandlerMaxId = 0;
|
||||
std::unordered_map<int, std::function<void(void)>>* keyUpHandlers = new std::unordered_map<int, std::function<void(void)>>();
|
||||
|
||||
int keyPressHandlerMaxId = 0;
|
||||
std::unordered_map<int, std::function<void(void)>>* keyPressHandlers = new std::unordered_map<int, std::function<void(void)>>();
|
||||
|
||||
int changeHandlerMaxId = 0;
|
||||
std::unordered_map<int, std::function<void(void)>>* changeHandlers = new std::unordered_map<int, std::function<void(void)>>();
|
||||
|
||||
int submitHandlerMaxId = 0;
|
||||
std::unordered_map<int, std::function<void(void)>>* submitHandlers = new std::unordered_map<int, std::function<void(void)>>();
|
||||
|
||||
int inputHandlerMaxId = 0;
|
||||
std::unordered_map<int, std::function<void(void)>>* inputHandlers = new std::unordered_map<int, std::function<void(void)>>();
|
||||
|
||||
int loadHandlerMaxId = 0;
|
||||
std::unordered_map<int, std::function<void(void)>>* loadHandlers = new std::unordered_map<int, std::function<void(void)>>();
|
||||
|
||||
int errorHandlerMaxId = 0;
|
||||
std::unordered_map<int, std::function<void(void)>>* errorHandlers = new std::unordered_map<int, std::function<void(void)>>();
|
||||
|
||||
int resizeHandlerMaxId = 0;
|
||||
std::unordered_map<int, std::function<void(void)>>* resizeHandlers = new std::unordered_map<int, std::function<void(void)>>();
|
||||
|
||||
int scrollHandlerMaxId = 0;
|
||||
std::unordered_map<int, std::function<void(void)>>* scrollHandlers = new std::unordered_map<int, std::function<void(void)>>();
|
||||
|
||||
int contextMenuHandlerMaxId = 0;
|
||||
std::unordered_map<int, std::function<void(void)>>* contextMenuHandlers = new std::unordered_map<int, std::function<void(void)>>();
|
||||
|
||||
int dragStartHandlerMaxId = 0;
|
||||
std::unordered_map<int, std::function<void(void)>>* dragStartHandlers = new std::unordered_map<int, std::function<void(void)>>();
|
||||
|
||||
int dragEndHandlerMaxId = 0;
|
||||
std::unordered_map<int, std::function<void(void)>>* dragEndHandlers = new std::unordered_map<int, std::function<void(void)>>();
|
||||
|
||||
int dropHandlerMaxId = 0;
|
||||
std::unordered_map<int, std::function<void(void)>>* dropHandlers = new std::unordered_map<int, std::function<void(void)>>();
|
||||
|
||||
__attribute__((import_module("env"), import_name("freeJs"))) void FreeJs(void* ptr);
|
||||
__attribute__((import_module("env"), import_name("getElementById"))) void* GetElementById(const char* id, std::size_t idLenght);
|
||||
void* GetElementById(const std::string_view id) {
|
||||
void* GetElementById(const std::string_view id) {
|
||||
return GetElementById(id.data(), id.size());
|
||||
}
|
||||
__attribute__((import_module("env"), import_name("setInnerHTML"))) void SetInnerHTML(void* ptr, const char* html, std::size_t htmlLenght);
|
||||
void SetInnerHTML(void* ptr, const std::string_view html) {
|
||||
void SetInnerHTML(void* ptr, const std::string_view html) {
|
||||
SetInnerHTML(ptr, html.data(), html.size());
|
||||
}
|
||||
|
||||
// Event handling functions
|
||||
__attribute__((import_module("env"), import_name("addClickListener"))) void AddClickListener(void* ptr, int id);
|
||||
__attribute__((import_module("env"), import_name("removeClickListener"))) void RemoveClickListener(void* ptr, int id);
|
||||
|
||||
__attribute__((import_module("env"), import_name("addMouseOverListener"))) void AddMouseOverListener(void* ptr, int id);
|
||||
__attribute__((import_module("env"), import_name("removeMouseOverListener"))) void RemoveMouseOverListener(void* ptr, int id);
|
||||
|
||||
__attribute__((import_module("env"), import_name("addMouseOutListener"))) void AddMouseOutListener(void* ptr, int id);
|
||||
__attribute__((import_module("env"), import_name("removeMouseOutListener"))) void RemoveMouseOutListener(void* ptr, int id);
|
||||
|
||||
__attribute__((import_module("env"), import_name("addMouseMoveListener"))) void AddMouseMoveListener(void* ptr, int id);
|
||||
__attribute__((import_module("env"), import_name("removeMouseMoveListener"))) void RemoveMouseMoveListener(void* ptr, int id);
|
||||
|
||||
__attribute__((import_module("env"), import_name("addFocusListener"))) void AddFocusListener(void* ptr, int id);
|
||||
__attribute__((import_module("env"), import_name("removeFocusListener"))) void RemoveFocusListener(void* ptr, int id);
|
||||
|
||||
__attribute__((import_module("env"), import_name("addBlurListener"))) void AddBlurListener(void* ptr, int id);
|
||||
__attribute__((import_module("env"), import_name("removeBlurListener"))) void RemoveBlurListener(void* ptr, int id);
|
||||
|
||||
__attribute__((import_module("env"), import_name("addKeyDownListener"))) void AddKeyDownListener(void* ptr, int id);
|
||||
__attribute__((import_module("env"), import_name("removeKeyDownListener"))) void RemoveKeyDownListener(void* ptr, int id);
|
||||
|
||||
__attribute__((import_module("env"), import_name("addKeyUpListener"))) void AddKeyUpListener(void* ptr, int id);
|
||||
__attribute__((import_module("env"), import_name("removeKeyUpListener"))) void RemoveKeyUpListener(void* ptr, int id);
|
||||
|
||||
__attribute__((import_module("env"), import_name("addKeyPressListener"))) void AddKeyPressListener(void* ptr, int id);
|
||||
__attribute__((import_module("env"), import_name("removeKeyPressListener"))) void RemoveKeyPressListener(void* ptr, int id);
|
||||
|
||||
__attribute__((import_module("env"), import_name("addChangeListener"))) void AddChangeListener(void* ptr, int id);
|
||||
__attribute__((import_module("env"), import_name("removeChangeListener"))) void RemoveChangeListener(void* ptr, int id);
|
||||
|
||||
__attribute__((import_module("env"), import_name("addSubmitListener"))) void AddSubmitListener(void* ptr, int id);
|
||||
__attribute__((import_module("env"), import_name("removeSubmitListener"))) void RemoveSubmitListener(void* ptr, int id);
|
||||
|
||||
__attribute__((import_module("env"), import_name("addInputListener"))) void AddInputListener(void* ptr, int id);
|
||||
__attribute__((import_module("env"), import_name("removeInputListener"))) void RemoveInputListener(void* ptr, int id);
|
||||
|
||||
__attribute__((import_module("env"), import_name("addLoadListener"))) void AddLoadListener(void* ptr, int id);
|
||||
__attribute__((import_module("env"), import_name("removeLoadListener"))) void RemoveLoadListener(void* ptr, int id);
|
||||
|
||||
__attribute__((import_module("env"), import_name("addErrorListener"))) void AddErrorListener(void* ptr, int id);
|
||||
__attribute__((import_module("env"), import_name("removeErrorListener"))) void RemoveErrorListener(void* ptr, int id);
|
||||
|
||||
__attribute__((import_module("env"), import_name("addResizeListener"))) void AddResizeListener(void* ptr, int id);
|
||||
__attribute__((import_module("env"), import_name("removeResizeListener"))) void RemoveResizeListener(void* ptr, int id);
|
||||
|
||||
__attribute__((import_module("env"), import_name("addScrollListener"))) void AddScrollListener(void* ptr, int id);
|
||||
__attribute__((import_module("env"), import_name("removeScrollListener"))) void RemoveScrollListener(void* ptr, int id);
|
||||
|
||||
__attribute__((import_module("env"), import_name("addContextMenuListener"))) void AddContextMenuListener(void* ptr, int id);
|
||||
__attribute__((import_module("env"), import_name("removeContextMenuListener"))) void RemoveContextMenuListener(void* ptr, int id);
|
||||
|
||||
__attribute__((import_module("env"), import_name("addDragStartListener"))) void AddDragStartListener(void* ptr, int id);
|
||||
__attribute__((import_module("env"), import_name("removeDragStartListener"))) void RemoveDragStartListener(void* ptr, int id);
|
||||
|
||||
__attribute__((import_module("env"), import_name("addDragEndListener"))) void AddDragEndListener(void* ptr, int id);
|
||||
__attribute__((import_module("env"), import_name("removeDragEndListener"))) void RemoveDragEndListener(void* ptr, int id);
|
||||
|
||||
__attribute__((import_module("env"), import_name("addDropListener"))) void AddDropListener(void* ptr, int id);
|
||||
__attribute__((import_module("env"), import_name("removeDropListener"))) void RemoveDropListener(void* ptr, int id);
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
__attribute__((export_name("ExecuteClickHandler"))) void ExecuteClickHandler(int a) {
|
||||
Crafter::CppDOM::Bindings::clickHandlers->find(static_cast<int>(a))->second();
|
||||
}
|
||||
|
||||
__attribute__((export_name("ExecuteMouseOverHandler"))) void ExecuteMouseOverHandler(int a) {
|
||||
Crafter::CppDOM::Bindings::mouseOverHandlers->find(static_cast<int>(a))->second();
|
||||
}
|
||||
|
||||
__attribute__((export_name("ExecuteMouseOutHandler"))) void ExecuteMouseOutHandler(int a) {
|
||||
Crafter::CppDOM::Bindings::mouseOutHandlers->find(static_cast<int>(a))->second();
|
||||
}
|
||||
|
||||
__attribute__((export_name("ExecuteMouseMoveHandler"))) void ExecuteMouseMoveHandler(int a) {
|
||||
Crafter::CppDOM::Bindings::mouseMoveHandlers->find(static_cast<int>(a))->second();
|
||||
}
|
||||
|
||||
__attribute__((export_name("ExecuteFocusHandler"))) void ExecuteFocusHandler(int a) {
|
||||
Crafter::CppDOM::Bindings::focusHandlers->find(static_cast<int>(a))->second();
|
||||
}
|
||||
|
||||
__attribute__((export_name("ExecuteBlurHandler"))) void ExecuteBlurHandler(int a) {
|
||||
Crafter::CppDOM::Bindings::blurHandlers->find(static_cast<int>(a))->second();
|
||||
}
|
||||
|
||||
__attribute__((export_name("ExecuteKeyDownHandler"))) void ExecuteKeyDownHandler(int a, const char* key, const char* code, int keyCode) {
|
||||
Crafter::CppDOM::Bindings::keyDownHandlers->find(static_cast<int>(a))->second();
|
||||
}
|
||||
|
||||
__attribute__((export_name("ExecuteKeyUpHandler"))) void ExecuteKeyUpHandler(int a, const char* key, const char* code, int keyCode) {
|
||||
Crafter::CppDOM::Bindings::keyUpHandlers->find(static_cast<int>(a))->second();
|
||||
}
|
||||
|
||||
__attribute__((export_name("ExecuteKeyPressHandler"))) void ExecuteKeyPressHandler(int a, const char* key, const char* code, int keyCode) {
|
||||
Crafter::CppDOM::Bindings::keyPressHandlers->find(static_cast<int>(a))->second();
|
||||
}
|
||||
|
||||
__attribute__((export_name("ExecuteChangeHandler"))) void ExecuteChangeHandler(int a) {
|
||||
Crafter::CppDOM::Bindings::changeHandlers->find(static_cast<int>(a))->second();
|
||||
}
|
||||
|
||||
__attribute__((export_name("ExecuteSubmitHandler"))) void ExecuteSubmitHandler(int a) {
|
||||
Crafter::CppDOM::Bindings::submitHandlers->find(static_cast<int>(a))->second();
|
||||
}
|
||||
|
||||
__attribute__((export_name("ExecuteInputHandler"))) void ExecuteInputHandler(int a) {
|
||||
Crafter::CppDOM::Bindings::inputHandlers->find(static_cast<int>(a))->second();
|
||||
}
|
||||
|
||||
__attribute__((export_name("ExecuteLoadHandler"))) void ExecuteLoadHandler(int a) {
|
||||
Crafter::CppDOM::Bindings::loadHandlers->find(static_cast<int>(a))->second();
|
||||
}
|
||||
|
||||
__attribute__((export_name("ExecuteErrorHandler"))) void ExecuteErrorHandler(int a) {
|
||||
Crafter::CppDOM::Bindings::errorHandlers->find(static_cast<int>(a))->second();
|
||||
}
|
||||
|
||||
__attribute__((export_name("ExecuteResizeHandler"))) void ExecuteResizeHandler(int a) {
|
||||
Crafter::CppDOM::Bindings::resizeHandlers->find(static_cast<int>(a))->second();
|
||||
}
|
||||
|
||||
__attribute__((export_name("ExecuteScrollHandler"))) void ExecuteScrollHandler(int a) {
|
||||
Crafter::CppDOM::Bindings::scrollHandlers->find(static_cast<int>(a))->second();
|
||||
}
|
||||
|
||||
__attribute__((export_name("ExecuteContextMenuHandler"))) void ExecuteContextMenuHandler(int a) {
|
||||
Crafter::CppDOM::Bindings::contextMenuHandlers->find(static_cast<int>(a))->second();
|
||||
}
|
||||
|
||||
__attribute__((export_name("ExecuteDragStartHandler"))) void ExecuteDragStartHandler(int a) {
|
||||
Crafter::CppDOM::Bindings::dragStartHandlers->find(static_cast<int>(a))->second();
|
||||
}
|
||||
|
||||
__attribute__((export_name("ExecuteDragEndHandler"))) void ExecuteDragEndHandler(int a) {
|
||||
Crafter::CppDOM::Bindings::dragEndHandlers->find(static_cast<int>(a))->second();
|
||||
}
|
||||
|
||||
__attribute__((export_name("ExecuteDropHandler"))) void ExecuteDropHandler(int a) {
|
||||
Crafter::CppDOM::Bindings::dropHandlers->find(static_cast<int>(a))->second();
|
||||
}
|
||||
}
|
||||
|
|
@ -37,7 +37,7 @@ namespace Crafter {
|
|||
CppDOM::Bindings::SetInnerHTML(ptr, html);
|
||||
}
|
||||
|
||||
// Event handling methods - simplified for now
|
||||
// Event handling methods
|
||||
int AddClickListener(std::function<void(void)> callback) {
|
||||
int id = CppDOM::Bindings::clickHandlerMaxId++;
|
||||
handlers.push_back(id);
|
||||
|
|
@ -52,8 +52,276 @@ namespace Crafter {
|
|||
CppDOM::Bindings::RemoveClickListener(ptr, id);
|
||||
}
|
||||
|
||||
int AddMouseOverListener(std::function<void(void)> callback) {
|
||||
int id = CppDOM::Bindings::mouseOverHandlerMaxId++;
|
||||
handlers.push_back(id);
|
||||
CppDOM::Bindings::mouseOverHandlers->insert({id, callback});
|
||||
CppDOM::Bindings::AddMouseOverListener(ptr, id);
|
||||
return id;
|
||||
}
|
||||
|
||||
void RemoveMouseOverListener(int id) {
|
||||
handlers.erase(std::remove(handlers.begin(), handlers.end(), id), handlers.end());
|
||||
CppDOM::Bindings::mouseOverHandlers->erase(id);
|
||||
CppDOM::Bindings::RemoveMouseOverListener(ptr, id);
|
||||
}
|
||||
|
||||
int AddMouseOutListener(std::function<void(void)> callback) {
|
||||
int id = CppDOM::Bindings::mouseOutHandlerMaxId++;
|
||||
handlers.push_back(id);
|
||||
CppDOM::Bindings::mouseOutHandlers->insert({id, callback});
|
||||
CppDOM::Bindings::AddMouseOutListener(ptr, id);
|
||||
return id;
|
||||
}
|
||||
|
||||
void RemoveMouseOutListener(int id) {
|
||||
handlers.erase(std::remove(handlers.begin(), handlers.end(), id), handlers.end());
|
||||
CppDOM::Bindings::mouseOutHandlers->erase(id);
|
||||
CppDOM::Bindings::RemoveMouseOutListener(ptr, id);
|
||||
}
|
||||
|
||||
int AddMouseMoveListener(std::function<void(void)> callback) {
|
||||
int id = CppDOM::Bindings::mouseMoveHandlerMaxId++;
|
||||
handlers.push_back(id);
|
||||
CppDOM::Bindings::mouseMoveHandlers->insert({id, callback});
|
||||
CppDOM::Bindings::AddMouseMoveListener(ptr, id);
|
||||
return id;
|
||||
}
|
||||
|
||||
void RemoveMouseMoveListener(int id) {
|
||||
handlers.erase(std::remove(handlers.begin(), handlers.end(), id), handlers.end());
|
||||
CppDOM::Bindings::mouseMoveHandlers->erase(id);
|
||||
CppDOM::Bindings::RemoveMouseMoveListener(ptr, id);
|
||||
}
|
||||
|
||||
int AddFocusListener(std::function<void(void)> callback) {
|
||||
int id = CppDOM::Bindings::focusHandlerMaxId++;
|
||||
handlers.push_back(id);
|
||||
CppDOM::Bindings::focusHandlers->insert({id, callback});
|
||||
CppDOM::Bindings::AddFocusListener(ptr, id);
|
||||
return id;
|
||||
}
|
||||
|
||||
void RemoveFocusListener(int id) {
|
||||
handlers.erase(std::remove(handlers.begin(), handlers.end(), id), handlers.end());
|
||||
CppDOM::Bindings::focusHandlers->erase(id);
|
||||
CppDOM::Bindings::RemoveFocusListener(ptr, id);
|
||||
}
|
||||
|
||||
int AddBlurListener(std::function<void(void)> callback) {
|
||||
int id = CppDOM::Bindings::blurHandlerMaxId++;
|
||||
handlers.push_back(id);
|
||||
CppDOM::Bindings::blurHandlers->insert({id, callback});
|
||||
CppDOM::Bindings::AddBlurListener(ptr, id);
|
||||
return id;
|
||||
}
|
||||
|
||||
void RemoveBlurListener(int id) {
|
||||
handlers.erase(std::remove(handlers.begin(), handlers.end(), id), handlers.end());
|
||||
CppDOM::Bindings::blurHandlers->erase(id);
|
||||
CppDOM::Bindings::RemoveBlurListener(ptr, id);
|
||||
}
|
||||
|
||||
int AddKeyDownListener(std::function<void(void)> callback) {
|
||||
int id = CppDOM::Bindings::keyDownHandlerMaxId++;
|
||||
handlers.push_back(id);
|
||||
CppDOM::Bindings::keyDownHandlers->insert({id, callback});
|
||||
CppDOM::Bindings::AddKeyDownListener(ptr, id);
|
||||
return id;
|
||||
}
|
||||
|
||||
void RemoveKeyDownListener(int id) {
|
||||
handlers.erase(std::remove(handlers.begin(), handlers.end(), id), handlers.end());
|
||||
CppDOM::Bindings::keyDownHandlers->erase(id);
|
||||
CppDOM::Bindings::RemoveKeyDownListener(ptr, id);
|
||||
}
|
||||
|
||||
int AddKeyUpListener(std::function<void(void)> callback) {
|
||||
int id = CppDOM::Bindings::keyUpHandlerMaxId++;
|
||||
handlers.push_back(id);
|
||||
CppDOM::Bindings::keyUpHandlers->insert({id, callback});
|
||||
CppDOM::Bindings::AddKeyUpListener(ptr, id);
|
||||
return id;
|
||||
}
|
||||
|
||||
void RemoveKeyUpListener(int id) {
|
||||
handlers.erase(std::remove(handlers.begin(), handlers.end(), id), handlers.end());
|
||||
CppDOM::Bindings::keyUpHandlers->erase(id);
|
||||
CppDOM::Bindings::RemoveKeyUpListener(ptr, id);
|
||||
}
|
||||
|
||||
int AddKeyPressListener(std::function<void(void)> callback) {
|
||||
int id = CppDOM::Bindings::keyPressHandlerMaxId++;
|
||||
handlers.push_back(id);
|
||||
CppDOM::Bindings::keyPressHandlers->insert({id, callback});
|
||||
CppDOM::Bindings::AddKeyPressListener(ptr, id);
|
||||
return id;
|
||||
}
|
||||
|
||||
void RemoveKeyPressListener(int id) {
|
||||
handlers.erase(std::remove(handlers.begin(), handlers.end(), id), handlers.end());
|
||||
CppDOM::Bindings::keyPressHandlers->erase(id);
|
||||
CppDOM::Bindings::RemoveKeyPressListener(ptr, id);
|
||||
}
|
||||
|
||||
int AddChangeListener(std::function<void(void)> callback) {
|
||||
int id = CppDOM::Bindings::changeHandlerMaxId++;
|
||||
handlers.push_back(id);
|
||||
CppDOM::Bindings::changeHandlers->insert({id, callback});
|
||||
CppDOM::Bindings::AddChangeListener(ptr, id);
|
||||
return id;
|
||||
}
|
||||
|
||||
void RemoveChangeListener(int id) {
|
||||
handlers.erase(std::remove(handlers.begin(), handlers.end(), id), handlers.end());
|
||||
CppDOM::Bindings::changeHandlers->erase(id);
|
||||
CppDOM::Bindings::RemoveChangeListener(ptr, id);
|
||||
}
|
||||
|
||||
int AddSubmitListener(std::function<void(void)> callback) {
|
||||
int id = CppDOM::Bindings::submitHandlerMaxId++;
|
||||
handlers.push_back(id);
|
||||
CppDOM::Bindings::submitHandlers->insert({id, callback});
|
||||
CppDOM::Bindings::AddSubmitListener(ptr, id);
|
||||
return id;
|
||||
}
|
||||
|
||||
void RemoveSubmitListener(int id) {
|
||||
handlers.erase(std::remove(handlers.begin(), handlers.end(), id), handlers.end());
|
||||
CppDOM::Bindings::submitHandlers->erase(id);
|
||||
CppDOM::Bindings::RemoveSubmitListener(ptr, id);
|
||||
}
|
||||
|
||||
int AddInputListener(std::function<void(void)> callback) {
|
||||
int id = CppDOM::Bindings::inputHandlerMaxId++;
|
||||
handlers.push_back(id);
|
||||
CppDOM::Bindings::inputHandlers->insert({id, callback});
|
||||
CppDOM::Bindings::AddInputListener(ptr, id);
|
||||
return id;
|
||||
}
|
||||
|
||||
void RemoveInputListener(int id) {
|
||||
handlers.erase(std::remove(handlers.begin(), handlers.end(), id), handlers.end());
|
||||
CppDOM::Bindings::inputHandlers->erase(id);
|
||||
CppDOM::Bindings::RemoveInputListener(ptr, id);
|
||||
}
|
||||
|
||||
int AddLoadListener(std::function<void(void)> callback) {
|
||||
int id = CppDOM::Bindings::loadHandlerMaxId++;
|
||||
handlers.push_back(id);
|
||||
CppDOM::Bindings::loadHandlers->insert({id, callback});
|
||||
CppDOM::Bindings::AddLoadListener(ptr, id);
|
||||
return id;
|
||||
}
|
||||
|
||||
void RemoveLoadListener(int id) {
|
||||
handlers.erase(std::remove(handlers.begin(), handlers.end(), id), handlers.end());
|
||||
CppDOM::Bindings::loadHandlers->erase(id);
|
||||
CppDOM::Bindings::RemoveLoadListener(ptr, id);
|
||||
}
|
||||
|
||||
int AddErrorListener(std::function<void(void)> callback) {
|
||||
int id = CppDOM::Bindings::errorHandlerMaxId++;
|
||||
handlers.push_back(id);
|
||||
CppDOM::Bindings::errorHandlers->insert({id, callback});
|
||||
CppDOM::Bindings::AddErrorListener(ptr, id);
|
||||
return id;
|
||||
}
|
||||
|
||||
void RemoveErrorListener(int id) {
|
||||
handlers.erase(std::remove(handlers.begin(), handlers.end(), id), handlers.end());
|
||||
CppDOM::Bindings::errorHandlers->erase(id);
|
||||
CppDOM::Bindings::RemoveErrorListener(ptr, id);
|
||||
}
|
||||
|
||||
int AddResizeListener(std::function<void(void)> callback) {
|
||||
int id = CppDOM::Bindings::resizeHandlerMaxId++;
|
||||
handlers.push_back(id);
|
||||
CppDOM::Bindings::resizeHandlers->insert({id, callback});
|
||||
CppDOM::Bindings::AddResizeListener(ptr, id);
|
||||
return id;
|
||||
}
|
||||
|
||||
void RemoveResizeListener(int id) {
|
||||
handlers.erase(std::remove(handlers.begin(), handlers.end(), id), handlers.end());
|
||||
CppDOM::Bindings::resizeHandlers->erase(id);
|
||||
CppDOM::Bindings::RemoveResizeListener(ptr, id);
|
||||
}
|
||||
|
||||
int AddScrollListener(std::function<void(void)> callback) {
|
||||
int id = CppDOM::Bindings::scrollHandlerMaxId++;
|
||||
handlers.push_back(id);
|
||||
CppDOM::Bindings::scrollHandlers->insert({id, callback});
|
||||
CppDOM::Bindings::AddScrollListener(ptr, id);
|
||||
return id;
|
||||
}
|
||||
|
||||
void RemoveScrollListener(int id) {
|
||||
handlers.erase(std::remove(handlers.begin(), handlers.end(), id), handlers.end());
|
||||
CppDOM::Bindings::scrollHandlers->erase(id);
|
||||
CppDOM::Bindings::RemoveScrollListener(ptr, id);
|
||||
}
|
||||
|
||||
int AddContextMenuListener(std::function<void(void)> callback) {
|
||||
int id = CppDOM::Bindings::contextMenuHandlerMaxId++;
|
||||
handlers.push_back(id);
|
||||
CppDOM::Bindings::contextMenuHandlers->insert({id, callback});
|
||||
CppDOM::Bindings::AddContextMenuListener(ptr, id);
|
||||
return id;
|
||||
}
|
||||
|
||||
void RemoveContextMenuListener(int id) {
|
||||
handlers.erase(std::remove(handlers.begin(), handlers.end(), id), handlers.end());
|
||||
CppDOM::Bindings::contextMenuHandlers->erase(id);
|
||||
CppDOM::Bindings::RemoveContextMenuListener(ptr, id);
|
||||
}
|
||||
|
||||
int AddDragStartListener(std::function<void(void)> callback) {
|
||||
int id = CppDOM::Bindings::dragStartHandlerMaxId++;
|
||||
handlers.push_back(id);
|
||||
CppDOM::Bindings::dragStartHandlers->insert({id, callback});
|
||||
CppDOM::Bindings::AddDragStartListener(ptr, id);
|
||||
return id;
|
||||
}
|
||||
|
||||
void RemoveDragStartListener(int id) {
|
||||
handlers.erase(std::remove(handlers.begin(), handlers.end(), id), handlers.end());
|
||||
CppDOM::Bindings::dragStartHandlers->erase(id);
|
||||
CppDOM::Bindings::RemoveDragStartListener(ptr, id);
|
||||
}
|
||||
|
||||
int AddDragEndListener(std::function<void(void)> callback) {
|
||||
int id = CppDOM::Bindings::dragEndHandlerMaxId++;
|
||||
handlers.push_back(id);
|
||||
CppDOM::Bindings::dragEndHandlers->insert({id, callback});
|
||||
CppDOM::Bindings::AddDragEndListener(ptr, id);
|
||||
return id;
|
||||
}
|
||||
|
||||
void RemoveDragEndListener(int id) {
|
||||
handlers.erase(std::remove(handlers.begin(), handlers.end(), id), handlers.end());
|
||||
CppDOM::Bindings::dragEndHandlers->erase(id);
|
||||
CppDOM::Bindings::RemoveDragEndListener(ptr, id);
|
||||
}
|
||||
|
||||
int AddDropListener(std::function<void(void)> callback) {
|
||||
int id = CppDOM::Bindings::dropHandlerMaxId++;
|
||||
handlers.push_back(id);
|
||||
CppDOM::Bindings::dropHandlers->insert({id, callback});
|
||||
CppDOM::Bindings::AddDropListener(ptr, id);
|
||||
return id;
|
||||
}
|
||||
|
||||
void RemoveDropListener(int id) {
|
||||
handlers.erase(std::remove(handlers.begin(), handlers.end(), id), handlers.end());
|
||||
CppDOM::Bindings::dropHandlers->erase(id);
|
||||
CppDOM::Bindings::RemoveDropListener(ptr, id);
|
||||
}
|
||||
|
||||
~HtmlElement(){
|
||||
for(int handler : handlers) {
|
||||
// Clean up all handlers based on type - this is a simplified approach
|
||||
// In practice, you'd want to track handler types to clean them properly
|
||||
CppDOM::Bindings::clickHandlers->erase(handler);
|
||||
CppDOM::Bindings::RemoveClickListener(ptr, handler);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue