Re: Forms : Toolbar Trigger

From: Andy Hardy <aph_at_ahardy.demon.co.uk>
Date: Thu, 1 Jul 1999 11:07:15 +0100
Message-ID: <dLTPIRAT3ze3EwHQ_at_ahardy.demon.co.uk>


In article <aRDe3.1192$nZ5.1652_at_nntpserver.swip.net>, BAMAN MOTIVALA <bmotivala_at_swipnet.se> writes
>Hello,
>
>I have created a simple 4 button toolbar with buttons for Save, Enter Query,
>Execute Query and Exit. I have also created a form level WHE-BUTTON-PRESSED
>trigger to respond to toolbar events. In the trigger I have used IF and ELSE
>IF statements to handle the button pressed events. As I think about adding
>more buttons to the toolbar I wonder if this is the best way to write the
>code.
>
>My question:
>
>Is there a better way to write this trigger than using :SYSTEM.TRIGGER_ITEM
>and a bunch of ELSE IFs?

It would be nice if there were a way of running procedures, etc. by name e.g. run_procedure('my_procedure') and you just stored the name of the procedure you wanted within the button or common field... I can't think of a way of doing this unless you fiddle about with setting up key-fn triggers and use the execute_trigger('') function. However, this wouldn't really save any coding and would hide the code away.

Your current method is clear, even if boring to write!

Andy
>
>My code:
>
>/* Form level WHEN-BUTTON-PRESSED */
>
>DECLARE
> button_pressed varchar2(50);
>BEGIN
> button_pressed := :SYSTEM.TRIGGER_ITEM;
>--save button
> IF button_pressed = 'TOOLBAR.SAVE'
> THEN
> COMMIT_FORM;
>--enter query button
> ELSE IF button_pressed = 'TOOLBAR.EQUERY'
> THEN
> SET_ITEM_PROPERTY('TOOLBAR.SAVE', ENABLED, PROPERTY_FALSE);
> ENTER_QUERY;
>--query button
> ELSE IF button_pressed = 'TOOLBAR.QUERY'
> Then
> EXECUTE_QUERY;
> SET_ITEM_PROPERTY('TOOLBAR.SAVE', ENABLED, PROPERTY_TRUE);
>--exit button
> ELSE IF button_pressed = 'TOOLBAR.EXIT'
> THEN EXIT_FORM;
>END IF;
>END IF;
>END IF;
>END IF;
>END;
>
>
>
>

-- 
Andy Hardy. PGP key available on request
===============================================================
Received on Thu Jul 01 1999 - 12:07:15 CEST

Original text of this message