Author Topic: Tooltips wanted  (Read 3343 times)

0 Members and 1 Guest are viewing this topic.

Offline krovit

  • Forum Regular
  • Posts: 179
    • View Profile
Tooltips wanted
« on: November 05, 2020, 10:36:29 am »
I am the one who always asks... Sorry

I need a minimalist system to print tool tips under the cursor (words or small sentences)... is there anything "ready" that I could adapt to my needs?


Nothing is easy, especially when it appears simple (and nothing could be as dangerous as trying to do good to others)

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 1145
  • Larger than life
    • View Profile
    • GitHub
Re: Tooltips wanted
« Reply #1 on: November 05, 2020, 10:37:41 am »
You could look at InForm. InForm has built-in tools for tooltips. Also, I've updated my pipecom code.
Shuwatch!

FellippeHeitor

  • Guest
Re: Tooltips wanted
« Reply #2 on: November 05, 2020, 10:42:09 am »
InForm is a complete GUI system, you may benefit from not having to worry about the user interface.

However, if all you want is a text that follows the mouse, InForm may be too much of overhead.

Either way, let me know if there's anything in InForm I can be of assistance with.

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 1145
  • Larger than life
    • View Profile
    • GitHub
Re: Tooltips wanted
« Reply #3 on: November 05, 2020, 10:44:22 am »
InForm is a complete GUI system, you may benefit from not having to worry about the user interface.

However, if all you want is a text that follows the mouse, InForm may be too much of overhead.

Either way, let me know if there's anything in InForm I can be of assistance with.
@FellippeHeitor I should have worded it differently. What I mean is that he should look at the code of how InForm does it.
Shuwatch!

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: Tooltips wanted
« Reply #4 on: November 05, 2020, 01:14:33 pm »
krovit: is this something, what you search?

Code: QB64: [Select]
  1. TYPE Button
  2.     X AS INTEGER 'X coordinate
  3.     Y AS INTEGER 'Y coordinate
  4.     Label AS STRING * 30
  5.     ButText AS STRING * 1
  6.  
  7. DIM B(5) AS Button
  8. 'set it!
  9.  
  10. FOR generate = 0 TO 5
  11.     B(generate).X = 100 + space
  12.     B(generate).Y = 100
  13.     B(generate).Label = "Button nr. " + STR$(generate)
  14.     B(generate).ButText = _TRIM$(STR$(generate))
  15.     space = space + 60
  16.  
  17.  
  18. 'draw it
  19. SCREEN _NEWIMAGE(800, 600, 256)
  20. BWidth = 50
  21. BHeight = 20
  22. FOR d = 0 TO 5
  23.     LINE (B(d).X, B(d).Y)-(B(d).X + BWidth, B(d).Y + BHeight), , B
  24.     COLOR 15
  25.     _PRINTSTRING (B(d).X + 21, B(d).Y + 4), B(d).ButText
  26.     '                      21: button width / 2 - fontwidth / 2  (default font width is 8, so 50 / 2 - 8 / 2 = 25 - 4 = 21  -> center to middle
  27. 'save screen image
  28.  
  29.  
  30.  
  31. 'and now use it...
  32.     t = 0
  33.     DO UNTIL t = 6
  34.         WHILE _MOUSEINPUT: WEND
  35.         MX = _MOUSEX
  36.         MY = _MOUSEY
  37.         LB = _MOUSEBUTTON(1)
  38.  
  39.         IF MX >= B(t).X AND MX <= B(t).X + BWidth THEN
  40.             IF MY >= B(t).Y AND MY <= B(t).Y + BHeight THEN
  41.                 COLOR 14, 1
  42.                 _PRINTMODE _FILLBACKGROUND
  43.                 _PRINTSTRING (B(t).X, B(t).Y + 16), _TRIM$(B(t).Label)
  44.                 '                              16: Default font height is 16, so label is displayed 1 row lower
  45.                 IF LB THEN
  46.                     COLOR 15, 0
  47.                     LOCATE 20, 1: PRINT "Button "; t; "pressed."
  48.                 END IF
  49.             END IF
  50.         END IF
  51.         t = t + 1
  52.     LOOP
  53.     'restore screen image
  54.     _DISPLAY
  55.     _PUTIMAGE , scr
  56.     _LIMIT 20
  57.  

Offline krovit

  • Forum Regular
  • Posts: 179
    • View Profile
Re: Tooltips wanted
« Reply #5 on: November 05, 2020, 03:29:37 pm »
krovit: is this something, what you search?


Ah! simple and effective!
I thought you had to save the entire screen image (or something like that), write with _PRINTSCREEN, and then reload the saved image.
I don't think there's any alternative.
However, as I said, your example is simple and I think I can implement it in my code.
Thank you.

In any case my request always remains valid.
i think the tooltip is a gadget that can be convenient on many occasions.

« Last Edit: November 05, 2020, 03:37:54 pm by krovit »
Nothing is easy, especially when it appears simple (and nothing could be as dangerous as trying to do good to others)

Offline krovit

  • Forum Regular
  • Posts: 179
    • View Profile
Re: Tooltips wanted
« Reply #6 on: November 05, 2020, 03:33:27 pm »
InForm is a complete GUI system, you may benefit from not having to worry about the user interface.
However, if all you want is a text that follows the mouse, InForm may be too much of overhead.
Either way, let me know if there's anything in InForm I can be of assistance with.

Thank you Fellippe.
InForm is a great resource and always surprises for the potential.

But it's like you said: it's too "cumbersome" to put something of its own into other projects.
I tried to understand how the built-in tooltip works but to "get it out" I think I should disassemble the whole system...

Nothing is easy, especially when it appears simple (and nothing could be as dangerous as trying to do good to others)

FellippeHeitor

  • Guest
Re: Tooltips wanted
« Reply #7 on: November 05, 2020, 04:20:08 pm »
It's a small cog in the engine indeed.