Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #9315
    ToadLoadin
    Member

    Hi,

    I want to toggle line number on/off via macro, so I wrote this function:

    function toggleLineNum() {
    var isLineNumOn = document.Config.General.ShowLineNumbers;
    document.Config.General.ShowLineNumbers = !isLineNumOn;
    }

    But nothing chages while invoking this function, any advice? :-)

    #9316
    webern
    Member

    To toggle Line Numbers via a macro you can use just this command alone:
    editor.ExecuteCommandByID(4530);

    #9317
    Yutaka Emura
    Keymaster

    Hi ToadLoadin,

    This is a frequently asked question. Please use Save() when you finished settings:


    cfg = document.Config;
    /// do something
    cfg.Save();

    Of course, you can use the EmEditor command “Line Number”, and there is a toolbar button for this command.

    #9318
    ToadLoadin
    Member

    Thank you webern and Yutaka! :-D

    #9319
    ToadLoadin
    Member

    Hi Yutaka,

    I rewrote my function to this:

    function toggleLineNum() {
    var cfg = document.Config;
    var isLineNumOn = document.Config.General.ShowLineNumbers;
    document.Config.General.ShowLineNumbers = !isLineNumOn;
    cfg.Save();
    }

    but it still does not work… :-(

    Yutaka wrote:
    Hi ToadLoadin,

    This is a frequently asked question. Please use Save() when you finished settings:


    cfg = document.Config;
    /// do something
    cfg.Save();

    Of course, you can use the EmEditor command “Line Number”, and there is a toolbar button for this command.

    #9320
    Yutaka Emura
    Keymaster

    Hi ToadLoadin,

    You should write like this:

    function toggleLineNum() {
    var cfg = document.Config;
    var isLineNumOn = cfg.General.ShowLineNumbers;
    cfg.General.ShowLineNumbers = !isLineNumOn;
    cfg.Save();
    }

    #9321
    ToadLoadin
    Member

    Yes, it works! Thank you! :-D

    Yutaka wrote:
    Hi ToadLoadin,

    You should write like this:

    function toggleLineNum() {
    var cfg = document.Config;
    var isLineNumOn = cfg.General.ShowLineNumbers;
    cfg.General.ShowLineNumbers = !isLineNumOn;
    cfg.Save();
    }

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.