How to create an event when the theme changes
P粉245276769
P粉245276769 2023-09-10 19:52:39
0
1
796

I want to host an event when the theme changes. Do not use setTheme().

var editor = ace.edit("editor");
ace.require("ace/ext/settings_menu").init(editor);
editor.session.setMode("ace/mode/java");
editor.setOptions({
    theme: "ace/theme/tomorrow_night_bright"
});

editor.on('changeTheme', function() {    -> This is not working
    console.log(editor.mode)
})

I tried change theme event and using $("#-theme").change() event but it doesn't work

P粉245276769
P粉245276769

reply all(1)
P粉103739566

There are themeChange and themeLoaded events on

editor.renderer, see https://github.com/ajaxorg/ace/blob/31bbd6ade094c1e142565837a4ee93c7931399a4/src/virtual_renderer.js#L1721

editor.renderer.on('themeChange', function() {
    // theme setting changed
})
editor.renderer.on('themeLoaded', function() {
    // theme loaded and applied to editor
})
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template