Forum > LCL

Questions about the OnShowHint events in TtoolBar and ToolButtons

(1/2) > >>

jamie:
I know that I can implement the Application.OnShowHint to intercept all hints and do any modifications if needed. How about the OnShowHint that lives in the TControl of most controls?

  Currently I am working with a TtoolBar and it sits above an active area where I really would like the HINT not to show when I rest over any of its TtoolButtons.

 I would like to intercept the TtoolButton OnShowHint or maybe even just the OnShowHint of the Tool bar when any of the buttons needs to show the hint.

  Does the OnShowHint of the TtoolBar trigger for any of its TtoolButtons ?

dsiders:

--- Quote from: jamie on November 14, 2022, 11:57:50 pm ---I know that I can implement the Application.OnShowHint to intercept all hints and do any modifications if needed. How about the OnShowHint that lives in the TControl of most controls?

  Currently I am working with a TtoolBar and it sits above an active area where I really would like the HINT not to show when I rest over any of its TtoolButtons.

--- End quote ---

For that, all you need is:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---ToolBar1.ShowHint := False;

--- Quote from: jamie on November 14, 2022, 11:57:50 pm --- I would like to intercept the TtoolButton OnShowHint or maybe even just the OnShowHint of the Tool bar when any of the buttons needs to show the hint.

  Does the OnShowHint of the TtoolBar trigger for any of its TtoolButtons ?

--- End quote ---

I don't see anything beyond the support provided for CM_HINTSHOW in TControl. That signals OnShowHint when assigned. But neither TToolBar nor TToolButton publish the OnShowHint event. Why? Probably because Delphi doesn't.

OnShowHint is public in TControl, so you can assign a routine at run-time.  I think TToolBar is the logical choice since it already handles ShowHint and ShowCaption for its buttons.

To be honest, I've never had the need to tweak hints... anywhere.


jamie:
Hmm.

 Maybe I didn't explain well enough.
   
  I don't want to know when to disable it, I want to be able to intercept it logically to recalculate the position of the popup message so that it still displays but in a different location, so it does not cover the active area. Example, above the Tool bar button instead of the bottom.

  Of course, I would need to ensure there is space up there and if not then allow it to show where it can at the moment.


  I fine it interesting that there is no OnShowHint published event that can capture this via the toolbar controls etc.

  If you study the information provided in that event, it will allow you to do just about anything you want with that message before it displays.


jamie:
Ok, I've come up with a block of test code that seems to not be too painful to implement.

 The real code will be applied to the buttons on the Toolbar and can set the OnShowHint event to point to a single handler.

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.FormCreate(Sender: TObject);begin  Button1.OnShowHint := @Self.ProcessHint;end; procedure Tform1.ProcessHint(Sender:TObject; HintInfo:PhintInfo);Begin  With HintInfo^ do  Begin    HintPos := HintControl.ControlToScreen(Point(10,-CurSorRect.Height));  end;End;                               
Like I said, this is just test code for now and the object of what I am trying to do is avoid the hint message to overlay active area that are just below.

 have a good day.

dsiders:

--- Quote from: jamie on November 15, 2022, 05:14:22 pm ---Ok, I've come up with a block of test code that seems to not be too painful to implement.

 The real code will be applied to the buttons on the Toolbar and can set the OnShowHint event to point to a single handler.

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.FormCreate(Sender: TObject);begin  Button1.OnShowHint := @Self.ProcessHint;end; procedure Tform1.ProcessHint(Sender:TObject; HintInfo:PhintInfo);Begin  With HintInfo^ do  Begin    HintPos := HintControl.ControlToScreen(Point(10,-CurSorRect.Height));  end;End;                               
Like I said, this is just test code for now and the object of what I am trying to do is avoid the hint message to overlay active area that are just below.

 have a good day.

--- End quote ---

Interesting.

It assumes the hint is in the control you're trying to avoid though. Perhaps the control rectangle and the hint rectangle do not overlap.

IAC, thanks for the follow up.

Navigation

[0] Message Index

[#] Next page

Go to full version