Menu In TextArea.

Hi,
I have a requirement of showing a menu in the textarea, so that on pressing 'ctrl-space' i have to show the list of possible items and on click of the selected item has to insert in the textarea wherever the cursor is located (Similar to code completion in IDE's). Can someone help me with code snippet it would be great.

Thanks,
Ranjith G

Comments

  • edited July 29

    Hey @Ranjith_G, we can achieve this by using the context menu and showing it upon the key combination press (ctrl+space). You can define any functionality inside the context menu that you want to use, I've included a small example of how you can insert values inside the textarea upon selecting an option from the context menu. Here's the example in question: https://snippet.webix.com/ufsjc544.

    Alternatively, you can use setValue if you want to completely replace the previous value inside the textarea, but to my thinking the case in my example is more relevant, where you insert additional values instead of completely replacing them.

  • Hi Dzmitry,
    Thanks for your response. I want to show the contextmenu at cursor position. Can you please help me in this.

    Regards,
    Ranjith G.

  • check this
    https://github.com/component/textarea-caret-position
    @dandv is the contributor
    you can combine this with webix.html.offset and get actual caret position on the screen
    https://docs.webix.com/api__html_offset.html

  • edited August 1

    This is further proof that Webix should implement pop-up menus in input boxes and text areas. See also this request.

    The good news is that the functionality is already there in the Comments widget. It just needs to be extracted out.

  • Hi all,

    We have already added this feature request to our backlog and will probably implement it in one of the future releases.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!