getSelectionEndLine always returns zero

Posted by Blackbear on Fri 28 Mar 2003 01:06 AM — 6 posts, 19,637 views.

USA #0
The following jscript:

function sendHi () {
line = world.GetLineInfo(world.getSelectionEndLine(), 1);
world.send("Line is:" + line + ", end-line is " + world.getSelectionEndLine());

}

when bound to the keypad, returns the following regardless of whether text has been selected in the output window:

You say: Line is:undefined, end-line is 0

Australia Forum Administrator #1
I see what you mean here, but the problem is that the selection tends to get cancelled when you type something, so that by the time the script executes the selection has gone.

You can make it work by selecting some text, opening an immediate window (Ctrl+I) and then typing:

world.note (world.GetSelectionEndLine ());

and hit "run". Then you will see a non-zero response.
USA #2
Ok, but I'm binding the function to a keypad event. That shouldn't clear the selection if a function is bound to it. What I want to be able to do is highlight a name, hit a key, and have it generate a "hello"

James
Australia Forum Administrator #3
I am investigating this. There seems to be a bug in MUSHclient's handling of selected text, however my interim result is it works better if you double-click the word rather than click-and-drag.

Once I get my example to work - whenever that is ;) - I will post the result.
USA #4
You're absolutely right, double-clicking works fine. Go figure.

James
Australia Forum Administrator #5
This problem is fixed in 3.35 - it actually was two problems. Double-clicking a word should also have not worked *evilgrin* - because it should have paused the output window, like clicking and dragging.

That has been fixed. However your script will now work, because I have rearranged the order in which things are done, so the selection will be valid when the script executes.