gg: use html5_canvas_name as the name of the canvas in gg.js.v too, similarly to gg.c.v

This commit is contained in:
Delyan Angelov 2023-08-13 17:45:19 +03:00
parent 33965bc29b
commit be1270540b
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
3 changed files with 7 additions and 7 deletions

View File

@ -190,7 +190,7 @@ fn main() {
create_window: true create_window: true
resizable: false resizable: false
window_title: 'snek' window_title: 'snek'
canvas: 'canvas' html5_canvas_name: 'canvas'
) )
app.gg.run() app.gg.run()

View File

@ -171,7 +171,7 @@ fn main() {
user_data: game user_data: game
frame_fn: frame frame_fn: frame
event_fn: on_event event_fn: on_event
canvas: 'canvas' html5_canvas_name: 'canvas'
) )
game.init_game() game.init_game()
game.gg.run() // Run the render loop in the main thread game.gg.run() // Run the render loop in the main thread

View File

@ -250,9 +250,9 @@ pub:
native_rendering bool // Cocoa on macOS/iOS, GDI+ on Windows native_rendering bool // Cocoa on macOS/iOS, GDI+ on Windows
// drag&drop // drag&drop
enable_dragndrop bool // enable file dropping (drag'n'drop), default is false enable_dragndrop bool // enable file dropping (drag'n'drop), default is false
max_dropped_files int = 1 // max number of dropped files to process (default: 1) max_dropped_files int = 1 // max number of dropped files to process (default: 1)
max_dropped_file_path_length int = 2048 // max length in bytes of a dropped UTF-8 file path (default: 2048) max_dropped_file_path_length int = 2048 // max length in bytes of a dropped UTF-8 file path (default: 2048)
canvas string html5_canvas_name string = 'canvas' // the id/name of the canvas element, that will be used to render GG apps
} }
const size = Size{0, 0} const size = Size{0, 0}
@ -330,8 +330,8 @@ pub fn new_context(cfg Config) &Context {
g.config = cfg g.config = cfg
g.window = dom.window() g.window = dom.window()
document := dom.document document := dom.document
canvas_elem := document.getElementById(cfg.canvas.str) or { canvas_elem := document.getElementById(cfg.html5_canvas_name.str) or {
panic('gg: cannot get canvas element') panic('gg: cannot get canvas element from cfg.html5_canvas_name.str')
} }
canvas := get_canvas(canvas_elem) canvas := get_canvas(canvas_elem)
g.canvas = canvas g.canvas = canvas