I got a table "table_content"
and another table "table_error"
1 Everything ok
13 NO CONNECTION
65 NO VALID DATA
I display the table_content in a form and by going with the mouse over a STATUS field (ie: STATUS = 12) the corresponding entry(ies) from a select
(here: select description from table_error where status = 12) should appear just like the TOOLTIP (here: TYPE-ERROR).
I tried to accomplish that too; didn't work using such a trigger (when-validate-item, post-change and similar) - tooltip was empty. It populates (for this purpose created) display field, but tooltip - no way.
Ideal trigger would be WHEN-MOUSE-ENTER, but it didn't work either.
I managed to populate a tooltip using WHEN-MOUSE-CLICK trigger. Disadvantage is that you have to click, leave field and re-enter it to see a tooltip.
I'd also suggest a slight change of your code, Tony (I guess Hudo would like to see different tooltip for different status):
where status = :block.status;
I got an advice from another forum, but haven't tried it yet, just wanted to let you know, maybe implement it earlier then I do....
Make a Control Block & add a Control item in it with bevel -- None.
Make a small Canvas & Place Text-item on it.
Now create a trigger when-mouse-enter on STATUS feild.
In this trigger write the query to Select Status description based on the Status value of current record & use Show Window/Show view built-ins to display the Canvas & text item.
Add triggers When-mouse-click,When-mouse-click,When-mouse-double-click & When-mouse-leave and use buil-ins Hide view/Hide Window to hide the Pop-up canvas.
Gosh! Set_item_property is uncomparably easier than another forum's solution. Besides, it uses another canvas which simulates a tooltip, not the tooltip itself.
This solution requires use of another field (canvas is already mentioned), several triggers ... I'm not sure I'd use it. Complicates your life too much. I'd say it would be easier to have STATUS field and, besides it, a display item that contains status' description.
Of course, if Tony doesn't solve WHEN-VALIDATE-ITEM problem
Littlefoot, that wasn't the only bug in my code! In the SET_ITEM_PROPERTY call I used the item value :block.status when I meant to use the item name 'block.status'.
The on-line help explains why WHEN-MOUSE-ENTER doesn't work:
Changing a tooltip's property in a When-Mouse-Enter trigger cancels the tooltip before it is ever shown.
What we need (but don't have) is a "SHOW_TOOLTIP" built-in that we can call from WHEN-MOUSE-ENTER.
On thinking about it further, I realise now that if the block is multi-row then mouse triggers are the only possible way to achieve this - because the user can move the mouse to any row, and the tooltip needs to change. Since WHEN-MOUSE-ENTER won't work, the only viable way seems to be WHEN-MOUSE-CLICK, as you say, which is not ideal. Maybe "rolling your own tooltips" is the only way.
My choice would be to recognise that Forms simply can't do dynamic tooltips, and go for something it can do instead, like a display item! One can waste a lot of one's life trying to make Forms do things it wasn't designed to do.
Re WHEN-VALIDATE-ITEM, that does seem to work for me - as far as it goes. I am using a simple block based on the EMP table. I have a procedure:
PROCEDURE set_tooltip IS
where empno = :emp.mgr;
set_item_property( 'emp.mgr', TOOLTIP_TEXT, 'Manager is '||v_text );
And a WHEN-VALIDATE-ITEM trigger on :EMP.MGR:
I did find that there needed to be a "default" tooltip_text value on the item, otherwise it only displayed the tooltip for the first record (even though I fired the W-V-I trigger on some other record!) - so I put "Don't Know" in the item property palette, and then it worked.
This, along with WHEN-NEW-RECORD-INSTANCE, might work fine for a single-row block, but it is unfortunately useless on a multi-row block because once set the tooltip applies to every row on the screen until you either navigate to a new record (e.g. click on an item in it) or update the item. We really need that WHEN-MOUSE-ENTER trigger solution that Forms denies us!