I am new to Objective c programming. I have created an application which has a UI with two buttons "Cancel" and "Ok". On clicking "Cancel", the application must terminate and clicking "Ok" must perform some task. Everything works fine. I am able to tab between these buttons and can call the required functionality by clicking space button.
All I want to do is, that when focus is on "Cancel" button(using tab key) then on clicking enter button from keyboard, my application should terminate and similarly, when focus is on "Ok" button then clicking enter should perform the desired functionality.
I have even set the 'setKeyEquivalent" property of the "Ok" and "Cancel" button, but I can only set unique keyequivalents. I also tried to read the title or tag value of the buttons and then call the required functionality but it didn't worked too.
Can someone please guide me how can I use enter button to invoke different functions depending upon the selected button in UI.
I think you don't want to set key equivalents for the buttons. You would want to override keyDown: and test for the enter key, then do the appropriate thing depending on which button had focus (which I think you could determine using NSWindow's firstResponder method).
Related
I have a text input with a submit button next to it. When the submit button is pressed I get one behavior. When the enter button on the keyboard is pressed, I get a slightly different behavior even though I have them both running the same exact function. This leads me to believe that when the enter button is pressed, some other function is also getting called. How do I go about preventing this default function from being called so that only my custom function is called?
I would like to hide the "Config structure" button in the header of the screen "Item derails: configuration" in the VA* transactions, for a certain item status.
I am debugging the Dynpro logic but it's quite difficult to find the right spot where I can implement my additional logic and what button it actually is (technically).
Any help and guidance is appreciated.
Thanks in advance.
Here is a way to locate the code which defines the buttons of the Application Toolbar in any Dynpro. You may then change the code to hide a button, etc.
The "Application Toolbar" is the line of buttons which appears at the top of the main screen area (what is shown in your screenshot), and it's selected by the ABAP statement SET PF-STATUS during the Process Before Output event of the Dynpro screen, right before the screen is displayed.
If you put the focus on the button (click without releasing and drag out of the button) and press the F1 key, you will see both the function code of the button and the GUI status it belongs to (screenshot for transaction code SE38):
Double-click the "Function" field to display the GUI Status:
You may then start the debugger (/h in the command field for instance) and use the feature "breakpoint at statement", to stop at every SET PF-STATUS. After the EXCLUDING word, you may exclude (hide) any function code you want (button, menu item or keyboard key; for information, here SYCR is not even defined in the GUI status, so it's ignored). As you can see, you may modify the code here:
I'm building on top of code that a previous developer has left me, and he left something that intrigued me quite a bit.
Basically on his menus, he has a TextBox to take in user input and a button next to it to submit the value of the TextBox (for example if the user wanted to select option 1, he would input 1 into the TextBox and click the button). However, the user could also press the Enter key while focusing the TextBox, and it would be treated as the submit button was clicked.
Now this is simple enough to do, but when I check the VB code behind the menu, there's no TextBox_Keydown(...) Handles TextBox.Keydown function anywhere, only the button click event. How is he doing this? He has several menus that are similar and I can't figure out how.
A standard dialog box, if not told to act otherwise, enter does default command button and escape does cancel. In VB look at the properties Default for the command button.
I discovered how he was doing it. He basically mapped the AcceptButton and CancelButton properties of the entire Windows Form to various button functions.
On a form where I display data, if the user clicks the text box I open a virtual keyboard (form) and allow them to click buttons to enter data. When this virtual keyboard is opened, if the path to open was from clicking a text box, the first click in the new form (virtual keyboard) is ignored. If the virtual keyboard form is opened from clicking a button (from the first form), it works fine. I can't find a difference between triggering the virtual keyboard form from either control.
It seems to me that your issue is one of focus. When you trigger the virtual keyboard form to open because of the textbox click, you are somehow immediately returning focus to the caller, and not to the newly opened form. Therefore, you might need something as simple as:
myForm.Focus()
...at the end of the code that is opening the form.
I say this because the first click is "ignored", as you say. I would guess that it's actually consuming that first click as a focus event, and then you get the clicks you want registered as you want after that.
So I am pretty new to Xcode and Objective C, I've been using it about 2 weeks now. I am building an app for OSX. One of the windows in the app has 5 text boxes, some labels and a submit button at the bottom. The submit button is linked to a method that closes the window, opens a new one and outputs the contents of the text boxes into one text field on the new window.
I had it working correctly, but now when I do anything but click on the top text field the submit method is called and the window closes. I can click on the black space in the window, but click on any of the objects calls the method. Also, pressing tab calls the method. I am not sure when I did to cause this error, but any insight or tips would be very useful.
Sorry if this is vague, I'm not even sure how to describe the problem. If you need any specific information please ask.
Try looking in Interface Builder. Ctrl Click or Right click on the each one of the fields that are responding with calling the function. See if they are linked to the function.
Also check the "responder" as was suggested earlier. You can do this by also right click or ctrl clicking the red responder box labeled "responder". See if anything in there maps to your function