khchen / wNim

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

Help needed: Embed hyperlink in lines of multiline style wTextCtrl #82

Open gogolxdong opened 3 years ago

gogolxdong commented 3 years ago

I have trouble to show something like

 someone shared <a>something</a>

which requires Hyperlink in the same line with TextCtrl just like a normal text with hidden url. wHyperlink is subclass of wStaticText, and is different from TextCtrl which only append string, by far the position of hyperlink calculated for absolute position from getLastPosition

var fontHeight:int
var fontWidth:int
let defaultTextHeight = console.getDefaultSize().height div 3

for line in console.getTitle().splitLines:
  var fontSize = getTextFontSize(line, console.mFont.mHandle, console.mHwnd)
  fontHeight = fontSize.height
  fontWidth = fontSize.width div line.runeLen
  break
...
var pos = console.positionToXY(console.getLastPosition())
var x = fontWidth * pos.x
var y = fontHeight * pos.y
hyperlinks[files[0]] = Hyperlink(console, label = name & ext, url = files[0], pos = (x, y))

which is a newline everytime.