Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #17409
    Bill_Stewart
    Participant

    Hi,
    I was trying to write a macro to implement a single-keystroke incremental search:
    1) Enable Find Toolbar if not enabled
    2) Set focus to Find Toolbar
    3) Enable Incremental Search on toolbar
    Short test script:

    var eeStatus = editor.QueryStatusByID(EEID_FINDBAR_INCREMENTAL);
    alert(eeStatus);

    However eeStatus doesn’t reflect whether Incremental Search is checked or not. So it seems QueryStatusByID method doesn’t work for this EEID_FINDBAR_INCREMENTAL command ID.
    Is this correct, or am I doing something wrong?
    If this is correct, I would like to request that QueryStatusByID reflect state for this command ID.
    Thanks!
    Bill

    #17410
    Stefan
    Participant

    “EEID_FINDBAR_INCREMENTAL” is not a ID, but a string, the name of that command.

    The ID is 4571

    See EmEditor Help – Command Reference – Search category

    Incremental Search (Find toolbar) command
    Toggles the Incremental Search button on the Find toolbar.
    Toggles the Incremental Search button on the Find toolbar. When Incremental Search is activated,
    EmEditor will search and highlight results as the user types.

    How to Run
    Default Menu: None
    All Commands: Search > Find Toolbar > Incremental Search
    Toolbar: None
    Status Bar: None
    Default Shortcut Key: None
    Plug-in Command ID
    EEID_FINDBAR_INCREMENTAL (4571)
    Macros
    [JavaScript]
    editor.ExecuteCommandByID(4571);

    Also take a look in the help for EmEditor Macro Reference – Editor Object > QueryStatusByID Method

    Retrieves the current status of the specified command, whether it is enabled and checked.
    [JavaScript]
    nStatus = editor.QueryStatusByID( nID );

    Parameters
    nID
    Specifies an integer indicating the Command ID to execute.
    See the Command Reference for the list of available commands.

    Return Values
    Returns a combination of the following values.
    eeStatusEnabled The command is enabled.
    eeStatusLatched The command is checked.

    .

    #17411
    Stefan
    Participant

    But I get always a “2” for eeStatus, no matter if the button is in pressed state or not? :confused:

    Test:

    editor.ExecuteCommandByID(4571); //Toggles the Incremental Search BUTTON on the Find toolbar
    
    var eeStatus = editor.QueryStatusByID(4571);
    alert("eeStatus: "        + eeStatus);          // 2
    alert("eeStatusLatched: " +  eeStatusLatched ); // 4
    alert("eeStatusEnabled: " +  eeStatusEnabled ); // 2

    The toggle command “4571” works, but we can’t get the state of that button back with QueryStatusByID().
    Me think, “4571” is not the ID of that button itself, but just the ID of the toggle command.
    So to answer your question beforehand, I have no glue if this increment search button itself has a own ID to get its state.

    .

    #17412
    Stefan
    Participant

    And BTW, this too doesn’t work for me:

    //Sets the focus to the Find toolbar
    editor.ExecuteCommandByID(4565);

    The focus is still on document.

    Sets the focus to the Find toolbar works for me only
    – by utilizing a keyboard shortcut or
    – by All Commands: Search > Set Focus to Find Toolbar

    Tested with 13.0.6 portable

    .

    #17413
    Bill_Stewart
    Participant

    Right, I forgot to include the line that declares EEID_FINDBAR_INCREMENTAL in my code. The code should be:

    var EEID_FINDBAR_INCREMENTAL = 4571;
    var eeStatus = editor.QueryStatusByID(EEID_FINDBAR_INCREMENTAL);
    alert(eeStatus);

    What I am saying is that QueryStatusByID(4571) always returns 2 regardless of the state of the incremental search button.
    I am using 13.0.6, x64 version.
    Bill

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