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

v:mouse_popup_col and v:mouse_popup_row are not implemented yet? #5171

Closed
Yggdroot opened this issue Nov 4, 2019 · 10 comments
Labels

Comments

@Yggdroot
Copy link

@Yggdroot Yggdroot commented Nov 4, 2019

vim/runtime/doc/popup.txt

Lines 855 to 858 in 197c6b7

A mouse click arrives as <LeftMouse>. The coordinates are in
v:mouse_popup_col and v:mouse_popup_row. The top-left screen cell of the
popup is col 1, row 1 (not counting the border).

echo v:mouse_popup_row

E121: Undefined variable: v:mouse_popup_row

@Yggdroot Yggdroot added the enhancement label Nov 4, 2019
@brammool

This comment has been minimized.

Copy link
Contributor

@brammool brammool commented Nov 4, 2019

@brammool brammool closed this in f8b036b Nov 6, 2019
@Yggdroot

This comment has been minimized.

Copy link
Author

@Yggdroot Yggdroot commented Nov 7, 2019

vim/runtime/doc/popup.txt

Lines 855 to 858 in 197c6b7

A mouse click arrives as <LeftMouse>. The coordinates are in
v:mouse_popup_col and v:mouse_popup_row. The top-left screen cell of the
popup is col 1, row 1 (not counting the border).

I think this document should be modified so as not to mislead users.

@brammool

This comment has been minimized.

Copy link
Contributor

@brammool brammool commented Nov 7, 2019

@Yggdroot

This comment has been minimized.

Copy link
Author

@Yggdroot Yggdroot commented Nov 8, 2019

Thanks.

manuelschiller added a commit to manuelschiller/vim that referenced this issue Nov 10, 2019
Problem:    Position unknown for a mouse click in a popup window.
Solution:   Set v:mouse_col and v:mouse_lnum. (closes vim#5171)
@Yggdroot

This comment has been minimized.

Copy link
Author

@Yggdroot Yggdroot commented Nov 11, 2019

v:mouse_win and v:mouse_winid are always 0 in Popup window.

brammool added a commit that referenced this issue Nov 11, 2019
Problem:    v:mouse_winid not set on click in popup window.
Solution:   Set v:mouse_winid. (closes #5171)
@Yggdroot

This comment has been minimized.

Copy link
Author

@Yggdroot Yggdroot commented Nov 12, 2019

Thanks.

@Yggdroot

This comment has been minimized.

Copy link
Author

@Yggdroot Yggdroot commented Nov 12, 2019

Can vim get the v:mouse_winid, v:mouse_col and v:mouse_lnum in normal window just like in popup window?

@brammool

This comment has been minimized.

Copy link
Contributor

@brammool brammool commented Nov 12, 2019

@Yggdroot

This comment has been minimized.

Copy link
Author

@Yggdroot Yggdroot commented Nov 13, 2019

I find some issues about v:mouse_winid, v:mouse_col and v:mouse_lnum, so still report it here.

  1. if there are more than one popup window, v:mouse_winid is always the id of the first popup window. And if click outside of the popup, the value does not change.
    Expected behavior is: click first popup, the id is winid of the first popup, click the second, the id is winid of the second popup, click outside of the popups, id is another value.
  2. value of v:mouse_col and v:mouse_lnum is not right.

test.vim

func! Filter(winid, key)
    echom v:mouse_winid v:mouse_lnum v:mouse_col
    if a:key == "\<Esc>"
        call popup_close(a:winid)
    endif
    return 0
endf

let id = popup_create(bufnr('%'), {
            \ "title": "test",
            \ "line": 1,
            \ "maxheight": 5,
            \ "padding":   [0, 0, 0, 1],
            \ "scrollbar": 0,
            \ "mapping":   1,
            \ "zindex":    1,
            \ "filter" :   "Filter"
            \})

call win_execute(id, "setlocal nu")

let id2 = popup_create(bufnr('%'), {
            \ "title": "test",
            \ "line": 8,
            \ "maxheight": 5,
            \ "padding":   [0, 0, 0, 1],
            \ "scrollbar": 0,
            \ "mapping":   1,
            \ "zindex":    9,
            \ "filter" :   "Filter"
            \})
call win_execute(id2, "setlocal nu")
echom id id2

Steps to reproduce:

  1. so %
  2. click the first character f in func!, it outputs xxx 2, 2, expected output is xxx, 1, 1
@brammool

This comment has been minimized.

Copy link
Contributor

@brammool brammool commented Nov 13, 2019

The position is computed based on the assumption that it's in the popup that the filter is for. But when there are multiple popups this would indeed be wrong. Let me rethink this. Perhaps we should just depend on the function to get the info and let the filter check the window ID to find out if the click was inside its popup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.