Skip to Main Content

Oracle Forms

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

how to create a trigger for Shift + A key press in oracle forms 12c

User_P0HY3Sep 3 2021

In oracle form builder, I want to use a trigger for Shift + A, (it just cant be any other key, dont ask me why please), but there are only a few specific KEY- triggers available. I just want to run some PL/SQL code whenever Shift + A is pressed in a form.

Im using oracle forms 12c.

Maybe I could use the trigger "when-custom-javascript-event" but I dont understand where to put the javascript code.

Help please. Thank you

Comments

Oh wow - I feel like a kid. You told us not to, so I have to ask... Why Shift+A? Just kidding
Regarding the Key-Triggers, I think you are misinterpreting how they work. The trigger names do not directly related to any particular key. You determine which key and action each trigger will work with by setting the KeyMapping as desired. This is explained in the documentation, but I will try to simplify it for you.
https://docs.oracle.com/en/middleware/developer-tools/forms/12.2.1.4/working-forms/configuring-and-managing-forms-services.html#GUID-8A31EB52-E383-4BE2-8D6D-964DD22E18F9
Let's assume you randomly chose to use the KEY-F0 trigger to add your code.
.1. In Fusion Middleware Control, access the Forms instance
image.png.2. Then access the Advanced Configuration page.
image.png.3. On the Advanced Config page, click on Select Key Binding Files.
.4. For most English (US) configurations, you will want to select "fmrweb.res" from the list. Then click on Save and Close.
image.png.5. The file you just selected will now be available in the list when you select Key binding from the Category list.
image.png.6. Be sure you are in Edit mode. Typically, if a production configuration, you would select Lock and Edit (padlock upper right side)
image.png.7. Now that you are in Edit mode, add the following anywhere in the file:

65 : 1 : "Shift+A" : 82 : "Function 0"

Here is the translation of what it means (this is explained in the comments of the file at the top):
65 is the ASCII code for the letter A
1 is the modifier code for Shift
Shift+A is the text the user would typically see in the Keys column of the "Show Keys" dialog. So you can enter whatever text you like. However, in the case of using the Forms Function numbers 83-90, these do not show up in the Show Keys dialog. If that is a problem for you, you can easily use almost any other that is not in use or that you will not need.
82 is the Forms Function. This is what maps you to the trigger KEY-F0 in your form.
Function 0 is the text that would typically appear in the Show Keys dialog in the Functions column. So as with the keys texts, you can enter whatever text you like. But again, in this case, function 82 will not be listed.
.8. Now that you have made your changes, Apply (button) them then Activate the changes (padlock upper right).
.9. Add the desired code to your form in the KEY-F0 trigger. Compile and run.

User_P0HY3

Thanks I didnt know you could do so much but i still have some questions.
If I do what u said, will it work when keyboard is in lowercase as well?(if Shift + a is pressed instead of Shift+A)
If I assign Shift + 1, Shift + 2 using ascii code 49,50... but when user presses shift + 1, wont it register as ! and @ or am I overthinking
and thanks again really u made this so much easier lol

One thing I just thought of is that, you should never remap something like SHIFT+A because if you do, the user will never be able to actually enter "A" without being interrupted by the code you attach to it. You should use something like Ctrl+Shift+A
Regarding your questions, when remapping the keys think of it as actually remapping the physical keys. Meaning, the ASCII value you use should be representative of the keys as it appears on the keyboard (in most cases). So when you look at the keyboard, you see A S D F G H, etc. These are the codes you would use. You would not use: a s d f g h and so on. Similar would be true of the numbers. 1 2 3 4 5 and not ! @ # $ %

User_P0HY3

thanks man. some last questions,
What line will I append in frmweb.res for Ctrl + Shift + A ?
Why will pressing just A fire the trigger for Shift + A ?

and actually I'm creating user-configured shortcuts to open forms from the main menu of our application (the main menu itself is a form actually (a hierarchical tree) )

main menu :
https://i.stack.imgur.com/7rWOY.png

thanks again

Regarding your questions, your custom entry can go anywhere. As for your last question, I don’t understand. Press the “a” key will not fire the trigger assuming you configured the mapping correctly.
I need to make something very clear. Although in some cases you can use a printable key combination with the Key triggers, doing so is not supported or recommended. So be sure to use something like Shift+Ctrl+A and not Shift+A

User_P0HY3

no, I mean what will be the "code" I will write instead of :

65 : 1 : "Shift+A" : 82 : "Function 0"

for Ctrl + Shift + A
thanks again

Read the comments in the file. It explains how each setting works and the needed values. Here is a portion of the text from the file's comments. Refer back to my earlier instructions and you will see my reference to why I used "1" as the modifier value.

# JAVA MODIFIERS NUMBER
# Equal to the sum of the values for the modifier keys:
#   0 = None
#   1 = Shift
#   2 = Control
#   4 = Meta
#   8 = Alt
#
1 - 7

Post Details

Added on Sep 3 2021
7 comments
1,228 views