This content is provided AS IS for archive purposes only. Content may be out of date with no guarantee of correctness.

Tooltips - Topics - Hag Gui for Cobra - Static

Main Article

Tooltips - Topics - Hag Gui for Cobra

When you create a hag gui element, there is often an optional tooltip parameter that you can specify.

If the mouse is hovering over an element with a tooltip, the exported string hag_tooltip will contain the contents of the tooltip, or an empty string "" otherwise.

This leaves it up to you to decide how to implement the tooltip - for example, you may choose to use a status bar instead of a classic tooltip.

Text created with the CreateHyperlink function will by default have a tooltip set to the path of the hyperlink (e.g. "http://www.google.co.uk/" or "program.exe --debug")

Tooltip example:

Program
   Uses

       hagC2D,
       cobra2D,
       keyset

Var
   frmMain: ^forms
       frmMain_btnExample: ^buttons
   
   background: Element

Begin

   SetAppName("Tooltip example")
   OpenScreen(320, 240, 32, FALSE, COB_SHOWBORDER+COB_SHOWCLOSE)
   background = CreateSprite(320,240)
   Cls(ToRGBA(235,233,237),background) ; Flip

   HagBaseDir("../../hag\")
   HagInit(320, 240, 1) // Start with a sprite_index of 1 because of the background sprite  
   HagLoadGuiTheme("xp")
   
   frmMain = CreateForm()
       frmMain_btnExample = CreateButton(frmMain, 60, 20, 200, "My Button", "Click this button to quit.")
   
   HagUpdateOnce()
   
   
   While ExitRequested = FALSE
       
       HagUpdateAll_AutoKeys()

       SetAppName(hag_tooltip) // Set the window title to the tooltip
       
       If ButtonClicked(frmMain_btnExample) then RequestExit
       If KeyHits(VK_ESCAPE) > 0 then RequestExit
       
       Flip
       Pause
(1)
   Wend
   
   HagFreeAll()
   CloseScreen()

End

And here's how it looks when the mouse hovers over the button:

Hag GUI tooltip example screenshot

The tooltip is empty when the mouse is not hovering over the button.

Stay Subscribed

Follow me on twitter @golightlyb, subscribe to the RSS feed or get updates by e-mail.

You can also contact me directly - I make an effort to reply to every e-mail.


Login
v0.34.archive