Skip to content

Commit

Permalink
create C API for setting element style
Browse files Browse the repository at this point in the history
  • Loading branch information
jakogut committed Sep 3, 2019
1 parent b489723 commit 7aaf415
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
7 changes: 7 additions & 0 deletions site/source/docs/api_reference/emscripten.h.rst
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,13 @@ Functions
Note that SDL’s ``SDL_ShowCursor`` command shows and hides the SDL cursor, not the OS one. This command is useful to hide the OS cursor if your app draws its own cursor.
.. c:function:: void emscripten_set_element_style(char *selector, char *property, char *value)
Sets an inline style property of a given element
:param char *selector: Name of element to set a style property on
:param char *property: Name of property to set
:param char *value: Value to assign to style property
.. c:function:: double emscripten_get_now(void)
Expand Down
7 changes: 7 additions & 0 deletions src/library_browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -1394,6 +1394,13 @@ var LibraryBrowser = {
styleSheet.insertRule('canvas.emscripten { border: 1px solid black; cursor: none; }', 0);
},

emscripten_set_element_style__proxy: 'sync',
emscripten_set_element_style__sig: 'viii',
emscripten_set_element_style: function(selector, property, value) {
var element = Module[selector];
if (element) element.style[property] = UTF8ToString(value);
},

emscripten_set_canvas_size__proxy: 'sync',
emscripten_set_canvas_size__sig: 'vii',
emscripten_set_canvas_size: function(width, height) {
Expand Down
1 change: 1 addition & 0 deletions system/include/emscripten/emscripten.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ double emscripten_get_device_pixel_ratio(void);
void emscripten_set_window_title(const char *);
void emscripten_get_screen_size(int *width, int *height);
void emscripten_hide_mouse(void);
void emscripten_set_element_style(const char *, const char *, const char *);
void emscripten_set_canvas_size(int width, int height) __attribute__((deprecated("This variant does not allow specifying the target canvas", "Use emscripten_set_canvas_element_size() instead")));
void emscripten_get_canvas_size(int *width, int *height, int *isFullscreen) __attribute__((deprecated("This variant does not allow specifying the target canvas", "Use emscripten_get_canvas_element_size() and emscripten_get_fullscreen_status() instead")));

Expand Down

0 comments on commit 7aaf415

Please sign in to comment.