all events
This commit is contained in:
parent
f40afe684a
commit
a9667d38fd
7 changed files with 1061 additions and 5 deletions
|
|
@ -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