{"action":"created","issue":{"url":"https://api.github.com/repos/mabe02/lanterna/issues/230","repository_url":"https://api.github.com/repos/mabe02/lanterna","labels_url":"https://api.github.com/repos/mabe02/lanterna/issues/230/labels{/name}","comments_url":"https://api.github.com/repos/mabe02/lanterna/issues/230/comments","events_url":"https://api.github.com/repos/mabe02/lanterna/issues/230/events","html_url":"https://github.com/mabe02/lanterna/issues/230","id":147948081,"number":230,"title":"Incorrect Placement of Popup Window for ComboBox","user":{"login":"dkartaschew","id":2052368,"avatar_url":"https://avatars.githubusercontent.com/u/2052368?v=3","gravatar_id":"","url":"https://api.github.com/users/dkartaschew","html_url":"https://github.com/dkartaschew","followers_url":"https://api.github.com/users/dkartaschew/followers","following_url":"https://api.github.com/users/dkartaschew/following{/other_user}","gists_url":"https://api.github.com/users/dkartaschew/gists{/gist_id}","starred_url":"https://api.github.com/users/dkartaschew/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dkartaschew/subscriptions","organizations_url":"https://api.github.com/users/dkartaschew/orgs","repos_url":"https://api.github.com/users/dkartaschew/repos","events_url":"https://api.github.com/users/dkartaschew/events{/privacy}","received_events_url":"https://api.github.com/users/dkartaschew/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-04-13T05:14:21Z","updated_at":"2016-04-17T14:09:44Z","closed_at":null,"body":"Hi,\r\nWhen using a ComboBox in a dialog that is centered on parent window, the popup window to make the user selection appears in an undesired position when the ComboBox is not in the top-left corner of the dialog.\r\n\r\nTo replicate:\r\n1. Create a parent window instance, centered on the screen. (Top left is 10,10 on global co-ordinate, and 50x10 in size).\r\n2. Create a dialog box, with a ComboBox underneath several other components. (Top left of dialog is 11,11 on global co-ordinate and is 40x15 in size), ComboBox is 23,12 on relation to the dialog co-ordinate).\r\n3. Open the ComboBox, and the popup window will be displayed, somewhere around 46,25 on the global co-ordinate.\r\n\r\nDebugging, the code, the ComboBox uses:\r\n```\r\npopupWindow = new PopupWindow();\r\npopupWindow.setPosition(toGlobal(getPosition().withRelativeRow(1)));\r\n((WindowBasedTextGUI) getTextGUI()).addWindow(popupWindow);\r\n```\r\nHowever, `toGlobal()` ends up calling `parent.toGlobal(getPosition().withRelative(position))` where `position` is the position of the combobox relative to the dialog...\r\n\r\nSo the call progress ends up being: (Assuming ComboBox is at position 23,12 relative to the dialog).\r\n```\r\npopupWindow.setPosition(toGlobal(getPosition().withRelativeRow(1)));\r\npopupWindow.setPosition(toGlobal(TerminalPosition(23,13));\r\n... which in AbstractComponent.toGlobal() ends up being:\r\nparent.toGlobal(getPosition().withRelative(TerminalPosition(23,13)));\r\nparent.toGlobal(TerminalPosition(46,25)));\r\n```\r\n\r\nWith the following modification to ComboBox, we obtained the desired result.\r\n```\r\npopupWindow = new PopupWindow();\r\npopupWindow.setPosition(toGlobal(new TerminalPosition(0, 1)));\r\n((WindowBasedTextGUI) getTextGUI()).addWindow(popupWindow);\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/mabe02/lanterna/issues/comments/211026324","html_url":"https://github.com/mabe02/lanterna/issues/230#issuecomment-211026324","issue_url":"https://api.github.com/repos/mabe02/lanterna/issues/230","id":211026324,"user":{"login":"mabe02","id":10136489,"avatar_url":"https://avatars.githubusercontent.com/u/10136489?v=3","gravatar_id":"","url":"https://api.github.com/users/mabe02","html_url":"https://github.com/mabe02","followers_url":"https://api.github.com/users/mabe02/followers","following_url":"https://api.github.com/users/mabe02/following{/other_user}","gists_url":"https://api.github.com/users/mabe02/gists{/gist_id}","starred_url":"https://api.github.com/users/mabe02/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mabe02/subscriptions","organizations_url":"https://api.github.com/users/mabe02/orgs","repos_url":"https://api.github.com/users/mabe02/repos","events_url":"https://api.github.com/users/mabe02/events{/privacy}","received_events_url":"https://api.github.com/users/mabe02/received_events","type":"User","site_admin":false},"created_at":"2016-04-17T14:09:44Z","updated_at":"2016-04-17T14:09:44Z","body":"Ok, should be fixed now"}}