Results 1 to 8 of 8
  1. #1
    Join Date
    Aug 2003
    Posts
    26

    Unanswered: result of select statement as TOOLTIP

    Hello,

    I got a table "table_content"
    ID STATUS
    1234 1
    1235 1
    1236 12
    1237 65
    1238 1
    1239 13


    and another table "table_error"
    STATUS Description
    1 Everything ok
    2 IO-ERROR
    12 TYPE-ERROR
    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).

  2. #2
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1
    What you need to do is set the TOOLTIP_TEXT property of the STATUS item whwnever it may have changed - e.g. in WHEN-NEW-RECORD-INSTANCE and WHEN-VALIDATE-ITEM perhaps:
    Code:
    DECLARE
      v_text table_error.description%TYPE;
    BEGIN
      select description
      into v_text
      from table_error
      where status = 12;
    
      set_item_property( :block.status, TOOLTIP_TEXT, v_text );
    END;
    For efficiency, you may want to pre-load all the status codes and descriptions into a local packaged collection or a record group, so that you don't need to keep going back to the database.

  3. #3
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    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):
    Code:
    select description
      into v_text
      from table_error
      where status = :block.status;
    So: why doesn't WHEN-VALIDATE-ITEM trigger work?

  4. #4
    Join Date
    Aug 2003
    Posts
    26
    Hi Littlefoot,


    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....

    Hi,
    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.

    Greetings hudo

  5. #5
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    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

  6. #6
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1
    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.

  7. #7
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1
    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:
    Code:
    PROCEDURE set_tooltip IS
      v_text VARCHAR2(100);
    BEGIN
      select ename
      into v_text
      from emp
      where empno = :emp.mgr;
    
      set_item_property( 'emp.mgr', TOOLTIP_TEXT, 'Manager is '||v_text );
    END;
    And a WHEN-VALIDATE-ITEM trigger on :EMP.MGR:
    Code:
    set_tooltip;
    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!

  8. #8
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    Oh well, never mind; it is a shame that tooltip won't work with a WHEN-MOUSE-ENTER trigger. On the other hand, it is not an Oracle Forms bug - it's a feature

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •