{"action":"created","issue":{"url":"https://api.github.com/repos/Shoes3/shoes3/issues/294","repository_url":"https://api.github.com/repos/Shoes3/shoes3","labels_url":"https://api.github.com/repos/Shoes3/shoes3/issues/294/labels{/name}","comments_url":"https://api.github.com/repos/Shoes3/shoes3/issues/294/comments","events_url":"https://api.github.com/repos/Shoes3/shoes3/issues/294/events","html_url":"https://github.com/Shoes3/shoes3/issues/294","id":193224305,"number":294,"title":"Popup text auto-scaling","user":{"login":"dredknight","id":12410314,"avatar_url":"https://avatars.githubusercontent.com/u/12410314?v=3","gravatar_id":"","url":"https://api.github.com/users/dredknight","html_url":"https://github.com/dredknight","followers_url":"https://api.github.com/users/dredknight/followers","following_url":"https://api.github.com/users/dredknight/following{/other_user}","gists_url":"https://api.github.com/users/dredknight/gists{/gist_id}","starred_url":"https://api.github.com/users/dredknight/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dredknight/subscriptions","organizations_url":"https://api.github.com/users/dredknight/orgs","repos_url":"https://api.github.com/users/dredknight/repos","events_url":"https://api.github.com/users/dredknight/events{/privacy}","received_events_url":"https://api.github.com/users/dredknight/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2016-12-02T21:40:47Z","updated_at":"2016-12-07T20:28:26Z","closed_at":null,"body":"Hello everyone,\r\n\r\nI have started work on popup text autoscaling.\r\n\r\n@BackOrder  I am fascinated by your approach but I dont understand why it doesnt work on all occassions.\r\nHere is your working code from the other ticket:\r\n```Ruby\r\nShoes.app(width: 250, height: 250) do\r\n    @menu = stack width: 100, left: 75, top: 100 do end\r\n    @menu.clear do\r\n        @b = background blue, curve: 15\r\n        @b2 = background yellow, curve: 15, left: 2, top: 2, height: @menu.height - 4\r\n        flow margin_left: 12, margin_top: 5 do\r\n            @p = para \"Say hello!\"\r\n        end\r\n        timer(0) { \r\n            @b.width = @p.width + 20\r\n            @b2.width = @b.width - 4\r\n        }\r\n    end\r\nend\r\n```\r\nAnd below you can see my code which does not work.\r\nWhat is important is the @box where message is set and the timer where the things happen but actually do not. Check the debug results when hovering over elements. Why the @box.width is 0 where at your case it is a valid number?\r\n\r\n```Ruby\r\nclass Tooltip < Shoes::Widget\r\n\r\n    def initialize ()\r\n         motion { |x, y| @move_left = x; @move_top = y }\r\n         @@menu1 = stack;\r\n    end\r\n\r\n    def show( options={} )\r\n         @@menu1.clear {    @@menu = stack height: 0 do end.hide }\r\n        offset, high, wide, text, stroke, size, font, back1, back2 = 10, options[:height], options[:width], options[:text], options[:stroke], options[:size], options[:font],  options[:border] || rgb(120,42,5,0.5), options[:background] || rgb(180,150,110,0.7) \r\n        @@menu.style width: offset + wide, height: offset + high\r\n        menu_left, menu_top = @move_left, @move_top;\r\n        @move_left + @@menu.width >= app.width + offset ? menu_left = @move_left - @@menu.width : nil\r\n        @move_top + @@menu.height >= app.height + offset ? menu_top = @move_top - 2*@@menu.height/3 : nil\r\n        @@menu.move(menu_left, menu_top)\r\n        @@menu.clear do\r\n            background back1, curve: 15\r\n            background back2, curve: 15, width: @@menu.width-4, height: @@menu.height - 4, left: 2, top: 2\r\n\t\t\tflow margin_left: offset, width: wide, height: high do\r\n                @box = para text, size: size, stroke: stroke, font: font, align: \"center\", justify: true\r\n            end\r\n\t\t   \t\r\n        end\r\n\r\n        timer(0) do\r\n\t\t\tw = @box.width + 20\r\n\t\t\th = 30\r\n\t\t\tdebug(\"w is #{w}, h is #{h}\")\r\n\t\t\t@@menu.style width: w, height: h\r\n\t\t\t@@menu.show \r\n\t\tend \r\n    end\r\n\r\n    def hide\r\n        @@menu.hide\r\n    end\r\nend \r\n\r\n\r\nShoes.app(title: \"Open Skillwheel v:0.70, database: HoMM 5.5 RC8b\", width: 1000, height: 730, resizable: false ) do\r\n\r\n        @tooltip = tooltip()\r\n\r\n        def sign (slot=nil, text=nil, width=nil, height=nil, border=nil, background=nil, font=nil, size=nil, stroke=nil )\r\n            slot.hover { @tooltip.show text: text, width: width, height: height, border: border, background: background , font: font , size: size, stroke: stroke }\r\n            slot.leave { @tooltip.hide }\r\n        end\r\n        sign ( image \"#{DIR}/static/app-icon.png\", width: 200, height: 200, left: 100, top: 100 ), \"All settings\", 200, 200, rgb(0,20,5,0.5), rgb(0,244,99,0.5), \"Vivaldi\", 20, brown\r\n        sign ( image \"#{DIR}/static/app-icon.png\", width: 200, height: 200, left: 320, top: 100 ), \"Mandatory settings only\", 200, 200\r\n        sign ( image \"#{DIR}/static/app-icon.png\", width: 200, height: 200, left: 620, top: 100 ), \"just text. Error message should appear when hovered\"\r\nend\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/Shoes3/shoes3/issues/comments/265563895","html_url":"https://github.com/Shoes3/shoes3/issues/294#issuecomment-265563895","issue_url":"https://api.github.com/repos/Shoes3/shoes3/issues/294","id":265563895,"user":{"login":"BackOrder","id":8844578,"avatar_url":"https://avatars.githubusercontent.com/u/8844578?v=3","gravatar_id":"","url":"https://api.github.com/users/BackOrder","html_url":"https://github.com/BackOrder","followers_url":"https://api.github.com/users/BackOrder/followers","following_url":"https://api.github.com/users/BackOrder/following{/other_user}","gists_url":"https://api.github.com/users/BackOrder/gists{/gist_id}","starred_url":"https://api.github.com/users/BackOrder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BackOrder/subscriptions","organizations_url":"https://api.github.com/users/BackOrder/orgs","repos_url":"https://api.github.com/users/BackOrder/repos","events_url":"https://api.github.com/users/BackOrder/events{/privacy}","received_events_url":"https://api.github.com/users/BackOrder/received_events","type":"User","site_admin":false},"created_at":"2016-12-07T20:28:26Z","updated_at":"2016-12-07T20:28:26Z","body":"![image](https://cloud.githubusercontent.com/assets/8844578/20985211/81b799f6-bc91-11e6-99f7-967931056b53.png)\r\n\r\n```ruby\r\n@@textfile = <<-END\r\n   This is a popup tooltip\r\n   It has been defined in a multiline file\r\n   Thank you for your cooperation.\r\nEND\r\n\r\n\r\nShoes.app(width: 250, height: 250) do\r\n    @menu = stack do end\r\n    @menu.clear do\r\n        @b = background blue, curve: 15\r\n        @b2 = background yellow, curve: 15, left: 2, top: 2, height: @menu.height - 4\r\n        flow  do\r\n          @p = []\r\n          @@textfile.each_line { |n|\r\n            @p << para(n)\r\n          }\r\n        end\r\n        timer(0) {\r\n            @width = 0\r\n            @height = 0\r\n            @p.each { |n|\r\n               @height += n.height\r\n               @width = n.width > @width ? n.width : @width\r\n            }\r\n\t\t\t\r\n            info(\"height is #{@height} width is #{@width}\")\r\n            @b.width = @width + 20\r\n            @b2.width = @b.width - 4\r\n        }\r\n    end\r\nend\r\n```"}}
{"actor":{"display_login":"BackOrder"}}