{"action":"created","issue":{"url":"https://api.github.com/repos/TomasMikula/RichTextFX/issues/128","labels_url":"https://api.github.com/repos/TomasMikula/RichTextFX/issues/128/labels{/name}","comments_url":"https://api.github.com/repos/TomasMikula/RichTextFX/issues/128/comments","events_url":"https://api.github.com/repos/TomasMikula/RichTextFX/issues/128/events","html_url":"https://github.com/TomasMikula/RichTextFX/issues/128","id":61040421,"number":128,"title":"Two problems positioning popup relative to caret","user":{"login":"gerdwagner","id":5216139,"avatar_url":"https://avatars.githubusercontent.com/u/5216139?v=3","gravatar_id":"","url":"https://api.github.com/users/gerdwagner","html_url":"https://github.com/gerdwagner","followers_url":"https://api.github.com/users/gerdwagner/followers","following_url":"https://api.github.com/users/gerdwagner/following{/other_user}","gists_url":"https://api.github.com/users/gerdwagner/gists{/gist_id}","starred_url":"https://api.github.com/users/gerdwagner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gerdwagner/subscriptions","organizations_url":"https://api.github.com/users/gerdwagner/orgs","repos_url":"https://api.github.com/users/gerdwagner/repos","events_url":"https://api.github.com/users/gerdwagner/events{/privacy}","received_events_url":"https://api.github.com/users/gerdwagner/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/TomasMikula/RichTextFX/labels/bug","name":"bug","color":"fc2929"},{"url":"https://api.github.com/repos/TomasMikula/RichTextFX/labels/has%20workaround","name":"has workaround","color":"bfe5bf"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-03-13T11:13:02Z","updated_at":"2015-04-03T09:21:32Z","closed_at":null,"body":"1. The positioning does not work right after the editors text was changed by calling\r\nStyledTextArea.replaceText(int start, int end, String text)\r\nand the caret was moved by the change. (A typically use case that does so is code completion). \r\nAfter the next user edit positioning works alright again.\r\n\r\n2.  With an initially opened and focused editor positioning the popup at the caret  bottom (PopupAlignment.CARET_BOTTOM) does not work. It shows up somewhere in the upper half of the caret.\r\n\r\n\r\nReproduction:\r\nBoth problems can be seen in the SQuirreL SQL FX snapshot 20150313_1200 which is based on RichTextFX 0.6.3, see\r\nhttp://sourceforge.net/projects/squirrel-sql/files/sqfx/squirrelsqlfx-snapshot-20150313_1200.zip/download\r\n\r\nIn the SQL editor use the code completion short cut (ctrl+space) to display the code completion popup."},"comment":{"url":"https://api.github.com/repos/TomasMikula/RichTextFX/issues/comments/89234491","html_url":"https://github.com/TomasMikula/RichTextFX/issues/128#issuecomment-89234491","issue_url":"https://api.github.com/repos/TomasMikula/RichTextFX/issues/128","id":89234491,"user":{"login":"gerdwagner","id":5216139,"avatar_url":"https://avatars.githubusercontent.com/u/5216139?v=3","gravatar_id":"","url":"https://api.github.com/users/gerdwagner","html_url":"https://github.com/gerdwagner","followers_url":"https://api.github.com/users/gerdwagner/followers","following_url":"https://api.github.com/users/gerdwagner/following{/other_user}","gists_url":"https://api.github.com/users/gerdwagner/gists{/gist_id}","starred_url":"https://api.github.com/users/gerdwagner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gerdwagner/subscriptions","organizations_url":"https://api.github.com/users/gerdwagner/orgs","repos_url":"https://api.github.com/users/gerdwagner/repos","events_url":"https://api.github.com/users/gerdwagner/events{/privacy}","received_events_url":"https://api.github.com/users/gerdwagner/received_events","type":"User","site_admin":false},"created_at":"2015-04-03T09:21:32Z","updated_at":"2015-04-03T09:21:32Z","body":"Hi Thomas,\r\n\r\nthank you for the workaround. \r\n\r\nHere is a bit of a refinement of the workaround for people who can only decide on the popup's anchor offset or alignment right when the popup is opened:\r\n\r\nSimply move and move back the caret from within the code that opens the popup. The code for this may be:\r\n\r\n      int caretPosition = _codeArea.getCaretPosition();\r\n\r\n      if(0 != caretPosition)\r\n      {\r\n         _codeArea.positionCaret(caretPosition - 1);\r\n         _codeArea.positionCaret(caretPosition);\r\n      }\r\n      else\r\n      {\r\n         _codeArea.positionCaret(caretPosition + 1);\r\n         _codeArea.positionCaret(caretPosition);\r\n      }\r\n\r\nA usual example where one can only decide on the popup's anchor offset when it is opened is code completion.\r\n\r\nNote:\r\nThis is a workaround for both of the problems mentioned in this issue."}}