khchen / wNim

Nim's Windows GUI Framework
MIT License
327 stars 17 forks source link

tooltip does not support multiline text #58

Closed retsyo closed 4 years ago

retsyo commented 4 years ago

I have tried \n, \r, '\r\nand\n\r`, but none gives a multiline tooltip

import wNim

var app = App()
var frame = Frame(title="demo", size = (320, 200), style=wDefaultFrameStyle or wModalFrame)

var statusBar = StatusBar(frame)
var panel = Panel(frame)

var btn1 = Button(panel, label="button")
btn1.tooltip = "button 1\n\rbutton2"

proc layout() =
    panel.layout:
        btn1:
            top == panel.top
            left == panel.left
            width == panel.innerWidth

btn1.wEvent_MouseEnter do ():
    statusBar.setStatusText(btn1.tooltip)

panel.wEvent_Size do ():
    layout()

layout()
frame.center()
frame.show()
app.mainLoop()
khchen commented 4 years ago

Try add this line:

btn1.tooltip = "button1\r\nbutton2"
btn1.setToolTip(maxWidth=150)

Reference: https://docs.microsoft.com/en-us/windows/win32/controls/implement-multiline-tooltips

retsyo commented 4 years ago

thanks

tips, the maxWidth can be 0, so it is not necessary to measure a accurate width