In Windows, if a column is too narrow to show full text, a tooltip appears inline and can show you the missing text:
It's important to note that hint window is inline with the text being displayed (i.e. it's not "below" the node).
This would be the equivalent of VirtualTreeview HintMode hmToolTip:
TVTHintMode = (
hmDefault, // show the hint of the control
hmHint, // show node specific hint string returned by the application
hmHintAndDefault, // same as hmHint but show the control's hint if no node is concerned
hmTooltip // show the text of the node if it isn't already fully shown
);
hmTooltip: show the text of the node if it isn't already fully shown
And also Hints; not just tooltips
Explorer also has the ability to show a hint, which is a hint windows that floats near, or below the cell being hovered:
This would be the equivalent in VirtualTreeview of hmHint:
hmHint: show node specific hint string returned by the application
And you handle the OnGetHint event.
Why not both?
Now comes the piece of resistance: Windows performing both functions, at the same time:
showing you the full text (if it's cut off) (ala hmTooltip)
as well as allowing me to add more text (ala hmHint)
But, if there is no additional text to show, it should continue to show just the inline tooltip:
And if it's not cut off at just: just the extra text:
I want that!
How can i do that?
Research effort
if i set HintMode to hmTooltip, then OnGetHint never fires (and i never get a chance to add custom information)
if i set HintMode to hmHint (or hmHintAndDefault), then OnGetHint event fires, but the tree will no longer display the cut-off portion
if the HintMode is hmHint, then the displayed hint will never be inline; but instead will always be below the cell
Is such a feature possible? At the very least i assume i'll have to re-invent all the cell measuring to figure out if the inplace text is cut off.
but the the only way i can get an OnGetHint event
is by setting HintMode to hmHint
but if HintMode is hmHint
then the hint will never be in-place
but if i set HintMode to hmTooltip to make it in-place
i'll never get the OnGetHint event
goto 10
Bonus Reading
Virtual StringTree: How to determine if the node text is completely shown?
Edit: Clarification
I hate to do this, because it implies an answer or an avenue that could be pursued. But imagine the following truth table:
OnGetHint IsTreeTextClipped Hint
========= ================= ==================
Empty No No hint
Empty Yes Inline tooltip
Non-empty No Hint below; shows only GetHint text only
Non-empty Yes Hint below; show both TreeText+CRLF+GetHint text
The problem is that you can never have an inline tooltip if OnGetHint is called.
you can either your OnGetHint called (hmHint)
or you can have an inline tooltip (hmTooltip)
but you can never have OnGetHint called, and if it returns nothing, defer to hmTooltip mode
How can i have OnGetHint called with, and if it returns nothing, defer to hmTooltip mode?
Of course, nothing says that OnGetHint has to be involved at all. That was only an example of how get hint text to the VirtualTrees for processing.
Related
Good afternoon,
I'm doing a project in delphi that uses editmask. I'm using the phone mask.
When clicking on edit to write the phone number, it goes to the last field on the right, so it is necessary to go back with the backspace to the beginning of the edit on the left.
i would like to find a way that when the user typed the number in the last field on the right, it was passed to the left. So on until you complete the phone field. It would be possible?
Using an example of what it would look like:
I couldn't think of a way to do it
The component is called TMaskEdit.
Just like anything that bases on TEdit putting the focus onto the control will by default put the text cursor at the end of its content
via keyboard, should .AutoSelect be FALSE and
via mouse if clicking behind any text (by default the text is aligned to the left).
You should have experienced this with the other components already. If you want the text cursor to always be at a certain position upon focusing the control, then do that in such an event handler:
for keyboard use OnEnter:
procedure TForm1.MaskEdit1Enter(Sender: TObject);
begin
(Sender as TMaskEdit).SelStart:= 1; // Second position
end;
and for mouse use OnClick with the same code.
It even works unbound to how the property .AutoSelect is set.
Using Backspace is the worst choice input wise, as it always deletes potential content and needs to be pressed several times to go to the first position. Why not using the Home key instead?
This is a strange one: This is the situation
The application builds an edit form at run-time from an XML document. The UI/UX design is such that there are three levels of nested TTabControls and for the final (lowest) level the TTabItem is created at run-time. This has a TVertScrollBox which itself contains a column-grid control of mine and that (at last!) contains the THtmlEditor.
The problem is that when the controls are built and the content loaded, the THtmlEdit initially ignores keydown. It will respond to mouse events, the caret can be positioned. Switching to a different top-level tab, or away from the whole application and back, then cures the issue and the editor responds to keydown messages.
I have tried putting a breakpoint in procedure THtmlEditor.KeyDown() ... and then tracing back up the call-chain. There doesn't seem to be anything behaving differently. I've paid particular attention to input focus, explicitly calling Editor.SetFocus even though that is apparently already called ...
I have tried putting a conditional breakpoint in function TPlatformWin.HandleMessage: Boolean; ... and my only observation is that when in non-working mode, the call to DispatchMessage(Msg) doesn't arrive at the editor, or its parent form.
I have tried to build a MDC for this, replicating the structure outlined above but ... that always works!
What can I try next?
Has anyone seen this behaviour (and fixed it)?
EDIT:
The detail I didn't mention -- didn't think about it -- is that for the error condition to show, the control focused before the THmtlEditor is a TWebBrowser. If I set focus on a TEdit after TWebBrowser and then to THtmlEditor it seems to work.
Grrr!
This is only half an answer, but for future reference, this is what I've done:
It's a bodge :-(
I've put a TEdit on the main form and set it invisible. I've then added a handler to the MainForm OnFocusChanged which sets a boolean trap-flag to track if TWebBrowser has previously been focused.
For the instances of THtmlEditor I've added an OnClick handler which checks the trap-flag and makes the TEdit visible, calls SetFocus on it, re-hide the TEdit and return True so that the THtmlEditor can re-set focus to itself. The trap-flag is to avoid unnecessarily losing focus if the user is just clicking in the THtmlEditor.
The next step -- which I may never get to -- would be to trace through the focus code for TEdit. My suspicion is that it all relates ITextInput which TEdit supports and THtmlEditor doesn't.
I'm using a TVirtualStringTree as a grid which is working pretty well.
I'm using the treeviews hint functionality to show a hint when the user positions the mouse over a cell. I've had to change HintMode to hmHint as I want my hints to appear regardless of the cell text length.
What I'm trying to do now is to display a different hint depending on whereabouts the mouse is within the cell.
I can do this no problem before the hint is displayed by using the OnGetHint event. My problem is this event is only raised a next time when the user moves the mouse to another cell.
I can't see to find a way to update the hint while its displayed and the mouse is moved within the same cell
I've looked at suggestions for other controls, using the Application's OnShowHint event but they just seem to make the hint disappear and not show again.
Anyone got any ideas?
Thanks
Update
After some investigation here is what I have found in case it helps someone come up with a solution:
The CMHintShow method sets the CursoRect field of the HintInfo record to the bounds of the cell. This seems to stop the VCl from triggering the hint code again until the mouse moves out of this rect (TApplication.HintMouseMessage).
If i set the CursorRect to something smaller than the cell bounds the hint will update. I use VTs in a few places for different purposes, so I can't make these changes directly. Would be good to get a solution that doesn't require this change.
In TBaseVirtualTree.CMHintShow right near the top, the code reads:
if PtInRect(FLastHintRect, HintInfo.CursorPos) then
Exit;
If you comment this out then the behaviour is closer to what you are looking for. The hint window won't show again if you move the mouse within the same cell, but if you click then it will.
I can't seem to find any way to make the hint window show in the same cell without that mouse click though!
Sure I've seen this done before but off-hand I can't find any examples.
I've got a TListView, set in 'report' viewstyle. It has about half a dozen subitems, and one thing we'd like to do is have the 'hint' (tooltip) on the listview dynamically show another field of data. That is, each time you move the mouse over any given row, the 'hint' would show some text relevant to that particular row.
I'm partway there - I can do this using the OnInfoTip method, but unfortunately once a tip has appeared, Windows seems to decide that I don't need to see a hint for the listview again until I move the mouse away from the listview and then back 'over' it again. Simply moving the mouse down to the next row, all-the-time keeping the mouse over the control, doesn't persuade the program to display the new hint.
Just to be clear - I've got OnInfoTip working so that the program does display the right hint relevant to the item I first moved the mouse over. Changing the hint text isn't the issue. The problem is that moving the mouse to another item in the listview doesn't cause the software to show a new hint. (Hope that makes sense).
Is there some proper way of getting this behaviour to work, or am I going to end up doing something icky with mouseovers and then manually drawing a hintbox (etc)?
check the following link:
Display Custom Hints for TListView Sub Items
Edit:
I just checked it now on delphi7 it's showing the hint for every row dynamically after moving the mouse on the listview.
Offtopic: This is simple in Virtual Treeview component, it is build-in feature.
i was using the OnInfoTip event (i didn't need hints for the subitems). the hint was "flashing" (show/hide/show/hide/show/hide/show/hide). found the listview's ShowHint was false. set it to True and it worked as it should.
My issue is with the thing Delphi progies scare to death - Rich Edit in Windows (XP and pre-XP versions).
Situation:
I have added EM_AUTOURLDETECTION in OnCreate of form. Target -> RichEdit1. Then, I have form, that is "collapsed" after showing form. RichEdit Control is sattic, visible and enabled, but it is "hidden" because form window is collapsed.
I can expand and collapse form, using Button1 and changing forms Constraints and Size properties.
After first time I expand form, the URL inside RichEdit1 control is highlighted. But, after second, third, fourth, etc... times I collapse and expand form, the RichEdit1 Control does not highlight URL anymore.
I have tried EM_SETTEXTMODE messages, also WM_UPDATEUISTATE, also basic WM_TEXT message -> no luck. It sems like this merssage really works ( enables detection ) while sending keyboard strokes ( virtual keycodes ), but not when text has been modified.
Also - I am thinking to rewrite code to make RichEdit Control dynamic. Would this fix the problem?
Maybe solution is to override OnPaint / OnDraw method to avoid highlight ( formatting ) losing when collapsing or expanding form?
Weird is that my Embarcadero Documentation says this function must work in any moment text has been modified. Why it does not work?
Any help appreciated. I am making this Community Wiki because this is common problem and togewther we cam find solution, right? :)
Also - follow-ups and related Question:
Override OnPaint
How to autodetect urls in RichEdit 2.0?
http://www.vbforums.com/archive/index.php/t-59959.html
I am not sure but is the window of the richedit recreated when geing from hide to show? If this is the case you might create your own derived TRichEdit class, override the function that creates the WIndows Handle (TWinControl.CreateHandle) and add EM_AUTOURLDETECTION there.