{"action":"created","issue":{"url":"https://api.github.com/repos/jupyter-widgets/ipywidgets/issues/1677","repository_url":"https://api.github.com/repos/jupyter-widgets/ipywidgets","labels_url":"https://api.github.com/repos/jupyter-widgets/ipywidgets/issues/1677/labels{/name}","comments_url":"https://api.github.com/repos/jupyter-widgets/ipywidgets/issues/1677/comments","events_url":"https://api.github.com/repos/jupyter-widgets/ipywidgets/issues/1677/events","html_url":"https://github.com/jupyter-widgets/ipywidgets/pull/1677","id":253201464,"number":1677,"title":"Add traits to Image widget for mouse position and clicks","user":{"login":"mwcraig","id":1147167,"avatar_url":"https://avatars1.githubusercontent.com/u/1147167?v=4","gravatar_id":"","url":"https://api.github.com/users/mwcraig","html_url":"https://github.com/mwcraig","followers_url":"https://api.github.com/users/mwcraig/followers","following_url":"https://api.github.com/users/mwcraig/following{/other_user}","gists_url":"https://api.github.com/users/mwcraig/gists{/gist_id}","starred_url":"https://api.github.com/users/mwcraig/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mwcraig/subscriptions","organizations_url":"https://api.github.com/users/mwcraig/orgs","repos_url":"https://api.github.com/users/mwcraig/repos","events_url":"https://api.github.com/users/mwcraig/events{/privacy}","received_events_url":"https://api.github.com/users/mwcraig/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":14,"created_at":"2017-08-28T00:37:05Z","updated_at":"2017-08-30T18:34:19Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/jupyter-widgets/ipywidgets/pulls/1677","html_url":"https://github.com/jupyter-widgets/ipywidgets/pull/1677","diff_url":"https://github.com/jupyter-widgets/ipywidgets/pull/1677.diff","patch_url":"https://github.com/jupyter-widgets/ipywidgets/pull/1677.patch"},"body":"This adds four new traits to the image widget, all pixel positions relative to the upper left corner of the image.\r\n\r\n+ `x_click` and `y_click`, the pixel position of the most recent mouse click.\r\n+ `x_mouse` and `y_mouse`, the pixel position of the mouse (changes triggered by the `mousemove` event on the front end).\r\n\r\n@ejeschke -- this moves in the direction of making a ginga widget easier. I think it might be better to add a `Canvas` widget for that (looks relatively straightforward).\r\n\r\nWhether this is the way to go for ginga or not this seems like a nice improvement to the `Image` widget.\r\n\r\nI'm happy to change trait names or rethink the approach.\r\n\r\nedit: add to do list:\r\n\r\n- [ ] Correctly handle calculation of raw pixel position when border and/or padding are non-zero. Currently pixel position is measured relationship  to upper left of the border.\r\n- [ ] Make click an event with a custom payload.\r\n- [ ] Catch keypresses using suggestions from https://github.com/jupyter-widgets/ipywidgets/pull/1677#issuecomment-325587748.\r\n- [ ] Make mouse monitoring optional.\r\n- [ ] Factor mouse interactivity out of the `Image` widget."},"comment":{"url":"https://api.github.com/repos/jupyter-widgets/ipywidgets/issues/comments/326080135","html_url":"https://github.com/jupyter-widgets/ipywidgets/pull/1677#issuecomment-326080135","issue_url":"https://api.github.com/repos/jupyter-widgets/ipywidgets/issues/1677","id":326080135,"user":{"login":"ejeschke","id":1305473,"avatar_url":"https://avatars3.githubusercontent.com/u/1305473?v=4","gravatar_id":"","url":"https://api.github.com/users/ejeschke","html_url":"https://github.com/ejeschke","followers_url":"https://api.github.com/users/ejeschke/followers","following_url":"https://api.github.com/users/ejeschke/following{/other_user}","gists_url":"https://api.github.com/users/ejeschke/gists{/gist_id}","starred_url":"https://api.github.com/users/ejeschke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ejeschke/subscriptions","organizations_url":"https://api.github.com/users/ejeschke/orgs","repos_url":"https://api.github.com/users/ejeschke/repos","events_url":"https://api.github.com/users/ejeschke/events{/privacy}","received_events_url":"https://api.github.com/users/ejeschke/received_events","type":"User","site_admin":false},"created_at":"2017-08-30T18:34:19Z","updated_at":"2017-08-30T18:34:19Z","author_association":"NONE","body":"> Does the widget need to return mouse location in image coordinates (i.e. taking into account any scaling done on the screen)? I assume yes (and is not too hard to implement)\r\n\r\nYes.  I assume that the (x, y) coordinate system is based in the upper left, but there is easy option if it is based in the lower right.  Basically we just need to know which pixel in the image the cursor is over.  \r\n\r\nIf we want full functionality, we would need the following events:\r\n* cursor down (with button)\r\n* cursor motion\r\n* cursor up (with button)\r\n* widget enter\r\n* widget leave\r\n* widget focus\r\n* key down\r\n* key up\r\n* scrolling (wheel or touchpad)\r\n* pinching\r\n\r\nBut like I said, if we could get \r\n* cursor down\r\n* cursor move\r\n* cursor up\r\n* key pressed\r\n\r\nit would handle about 95%+ of the functionality."}}
{"actor":{"display_login":"ejeschke"}}