Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Best way to fire event after autocomplete is selected? #28

Open
JohnMcLear opened this issue Jun 12, 2016 · 5 comments
Open

Best way to fire event after autocomplete is selected? #28

JohnMcLear opened this issue Jun 12, 2016 · 5 comments

Comments

@JohnMcLear
Copy link
Contributor

What's the best way to do this? I want to fire

setAttributeOnLine(thisLineNumber, 'context', selectedValue);
@jdittrich
Copy link
Owner

I currently do not deal very much with etherpad plugin programming (sadly), but I see what I can do.

To clarify:

  1. selected means "an autocomplete option is selected and enter was just pressed (it will be inserted now) OR "user navigated in the autocomplete options with ↓↑ keys to choose another entry to be inserted when enter is pressed"?
  2. The setAttributeOnLine-Event seems to be undocumented. Is that right or did I oversee it? (It seems not to be in my code and neither is it in the manual, it seems)
  3. If I interpret this correctly, firing this even would inform the other authors that you just did a selection (of which nature I am unsure, see 1.)

@JohnMcLear
Copy link
Contributor Author

  1. Selected as in the user chooses that suggestion
  2. That's probably something I need to sort -.-
  3. I basically want to perform an event that another plugin currently does... It adds a like attribute..

On 12 Jun 2016 20:26, jdittrich [email protected] wrote:

I currently do not deal very much with etherpad plugin programming (sadly), but I see what I can do.

To clarify:

  1. selected means "an autocomplete option is selected and enter was just pressed (it will be inserted now) OR "user navigated in the autocomplete options with ↓↑ keys to choose another entry to be inserted when enter is pressed"?
  2. The setAttributeOnLine-Event seems to be undocumented. Is that right or did I oversee it? (It seems not to be in my code and neither is it in the manual, it seems)
  3. If I interpret this correctly, firing this even would inform the other authors that you just did a selection (of which nature I am unsure, see 1.)


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHubhttps://github.com//issues/28#issuecomment-225429648, or mute the threadhttps://github.com/notifications/unsubscribe/AANewIOKIihSaiUoVmDcyMjq-J93cArOks5qK_rvgaJpZM4IzxeV.

@jdittrich
Copy link
Owner

OK that helps along.

So it would help you if I point out at which part of the code that event could be fired? Like "I suggest line 42 in examplefile.js, since the function somefunc is always executed when a user selects an entry"

Would something like this be OK? – I assume that then you could try to insert a that event-firing code at the suggested position.

@jdittrich
Copy link
Owner

  • Text is entered after a user selects a suggestion in selectSuggestion
  • The selection of an entry in the list of possible autocompletes happens via moveSelectionUp and moveSelectionDown

→ if it is about selecting with the ↓↑ keys, there is not one function, but the up- and the down-function that need to be considered.

All of the mentioned functions are in /static/js/autocomp.js

@lpagliari
Copy link
Collaborator

@JohnMcLear do you want to autocomplete too? I mean, when the user selects a suggestion do you want sendkeys to be called, besides setting the line attribute as you mentioned on your original question?

If you don't want that to happen, I would suggest to change autocomp.js to be configured with a custom behavior besides the default one (call sendkeys and change the pad text). You could extract this code into a "default behavior" and return suggestionText on the selectSuggestion method, instead of a boolean. You can find custom options here.

Does that help you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants