Introduction
If you are like me, you probably haven’t had an opportunity to use a Forms Popup (Context) menu before. Recently, I was presented with an opportunity where a Popup menu made sense and would make the user experience better. Since I had never used one before it took me a little time to research how to create and use one. As I was researching how to do this I discovered that there really wasn’t very much published information on how to use a Popup menu and Popup menu’s are not very well documented in the Forms Help system. So, I decided to write this little “How to” document to demonstrate how I implemented a Popup menu.
My customer wanted a Popup menu to let them Copy, Cut and Paste a value from one item to another.
First off, I found it strange that Oracle Forms calls this menu a “Popup.” Standard User Interface (UI) programming refers to this type of menu as a “Context” menu. Since we are working with Oracle Forms, I will continue to refer to this menu as a Popup instead of the industry standard of Context.
Disclaimer
This demonstration is written using Oracle Developer Suite 10g Release 2 (10.1.2.0.2) with no patches installed. This makes the demo files included with this article usable by any version of Forms 10g. The concepts presented in this demo work with Forms 6i and 9i without any changes at all.
This demo assumes you have access to the HR demo schema.
Let’s get started…
Start the Forms OC4J Instance and then Forms Builder and connect to the HR demo schema. Create a new Forms module and create a new Data Block using the Data Block Wizard. Select the EMPLOYEES table and accept all of the default settings specified by the data block wizard – to include creating a canvas (selecting the Form layout). You should have something similar to the following:
Now, let’s create the Popup Menu, so scroll to the “Popup Menus” node of the Object Navigator and add (click on the node and click the + toolbar button) a popup menu object. Once added, right click the object and open the Property Pallet. Rename the object to “CONTEXT_MENU”. No other properties need to be changed at this point.
Now, let’s add the three menu options; Copy, Cut and Paste so click on the CONTEXT_MENU object and add three new menu items. Click on the first new object and then open the property pallet. Change the following properties:
1. Menu Item 1:
a. Name = COPYb. Label = Copy (Ctrl + C)c. Magic Item = Copyd. Menu Item Code = COPY_REGION;
2. Menu Item 2:
a. Name: CUTb. Label: Cut (Ctrl + X)c. Magic Item = Cutd. Menu Item Code = CUT_REGION;
3. Menu Item 3:
a. Name = PASTEb. Label = Paste (Ctrl + V)c. Magic Item = Pasted. Menu Item Code = PASTE_REGION;
Your form should now look similar to the following:
Now we need to assign the Popup menu to each item in the EMPLOYEES block. The easiest way to do this is to select all of the items in the block and open the property pallet. Scroll to the Popup Menu property and select the CONTEXT_MENU from the List of property values. For example:
That’s it! You’re done! Now just run your form to test. Your form should function similar to the following:
The kicker to this process is that you have to implement the "Popup Menu" on each item you want to use on.
Now that you have completed this little demo, I'm sure you have come to the same conclusion I did; "Boy, that was easy!"
No comments:
Post a Comment