added view

This commit is contained in:
Jorijn van der Graaf 2025-11-10 22:46:05 +01:00
commit 580e53d3bc
11 changed files with 68 additions and 34 deletions

View file

@ -105,6 +105,10 @@ extern "C" {
std::free(ptr);
}
__attribute__((export_name("deleteElement"))) void DeleteElement(void* ptr) {
// This will be implemented in JavaScript
}
__attribute__((export_name("ExecuteClickHandler"))) void ExecuteClickHandler(std::int32_t handlerID, double clientX, double clientY, double screenX, double screenY, std::int32_t button, std::int32_t buttons, bool altKey, bool ctrlKey, bool shiftKey, bool metaKey) {
Crafter::CppDOMBindings::clickHandlers->find(handlerID)->second(Crafter::MouseEvent(clientX, clientY, screenX, screenY, button, buttons, altKey, ctrlKey, shiftKey, metaKey));
}

View file

@ -136,4 +136,6 @@ export namespace Crafter::CppDOMBindings {
bool HasClass(void* ptr, const std::string_view className) {
return HasClass(ptr, className.data(), className.size());
}
__attribute__((import_module("env"), import_name("deleteElement"))) void DeleteElement(void* ptr);
}

View file

@ -18,7 +18,7 @@ License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
export module Crafter.CppDOM:HtmlElementView;
export module Crafter.CppDOM:HtmlElement;
import std;
import :BindingsExport;
import :BindingsImport;
@ -139,8 +139,9 @@ namespace Crafter {
};
export class HtmlElement : public HtmlElementView {
HtmlElementView(const std::string_view id);
HtmlElementView(const std::string_view id, const std::string_view html);
~HtmlElementView();
}
public:
HtmlElement(const std::string_view id);
HtmlElement(const std::string_view id, const std::string_view html);
~HtmlElement();
};
}