Triggering callback without pressing the button in Cocoa - objective-c

I need to be able to start the authentication process in this sample without pressing the button provided by default.
The action I want to run is the -(void)buttonPressed method, but if I try to invoke it manually the plugin crashes. It's invoked automatically by pressing that button but it would be nice to be able to just press enter.

This should all be obvious after a single glance in the plugin source code you linked!
While it shouldn't crash (after a quick look into the class code), you probably do not supply the appropriate sender when sending buttonPressed: from your code. The method is defined as
- (void)buttonPressed:(SFButtonType)inButtonType
Which clearly shows the button that was pressed is given as sender. So in your code when calling buttonPressed: do for example like:
["referenceRToClass" buttonPressed:SFButtonTypeOK];

Related

How to use "preventDefault" equivalent for React Native Text Input onSubmitEditing?

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?

When calling a Lotusscript agent from a button on the web, how can I add a spinner so that until the agent is done the user knows it is processing?

I have a Lotusscript agent behind a submit button that takes a while to do everything....the user needs to know it is processing so that they do not click the button multiple times.
Am using #Command([RunAgent];"agentname") to kick the agent off.
How in Lotusscript could I add some kind of 'processing' indication, either a progress bar or a spinner or something? I suppose I could embed some javascript inside the lotusscript, but hoping someone has a clean example or some tips to do this.
Maybe hiding the submit button at the same time if I use javascript via a display property on a surrounding the button would help too.
You can't do this with LotusScript coding, and while hiding the Submit button is a good idea, you're going to have to know when to unhide it. A simple #Command([RunAgent]...) call won't give you a way to do that.
You're going to have to redesign your form to include a significant amount of JavaScript and make an AJAX-style call to invoke your agent asynchronously via a ?OpenAgent URL sent in a POST request via XMLHttpRequest. Your main JavaScript code will continue after the call and launch the spinner, and the callback that you set up to handle the asynch return from the XMLHttpRequest can then either transition to a new page or stop the spinner by setting a variable that the spinner is checking once every second or two.

"Button.performclick()" vs"Call Button_Click(sender, e)"

What is the difference between Button.performclick() vs Call Button_Click(sender, e)? When should I use which one (if it matters in the first place)?
PerformClick is a method by which the control will raise the click event where as Button_Click(sender, e) is the event's method event handler. Both will probably do what are wanting to do.
Personally, I would suggest using the neither and instead wrap the code in the Click event into a sub, then calling the Sub in the Click event and calling the Sub in in lieu of the PerformClick.
Call exists mainly for compatibility when updating older VB6-era code to VB.Net. There's no good reason to use it in VB.Net.
That said, I almost never use performClick(). If I need to manually call the button click code from elsewhere I tend to either just write Button_Click(sender, e) (no Call) or, even better, create a new method to host the button click code, so both the button click event and my other code will call this new method instead.

How to break whenever any line of code executes

I have a very strange bug, which I believe is caused by some code we have executing, but I'm not sure where.
We can reproduce it to the point it happens whenever we click Tab, but short of putting a break point at the beginning of every method in the project to find out what is executing.
Is there a way to set visual studio to break whenever anything executes?
For those curious about the problem, every now and then, we have a few Rich Text Boxes that refuse to lose focus. You can't click out of it or tab out of it.
We have no On Validation or On Text Changed events attached to the control, and believe it's an event attached somewhere else to something we just aren't noticing.
You can set a breakpoint in the WndProc method, which will run whenever Tab is pressed.

NSWindow does not respond to keystroke command-s

It may be very simple, but I cannot find it:
I have three windows in three separate NIBs in my application. One is opened when a new document is opened, the other two can be opened from the program's window menu.
The problem is: two windows (in them the one that is opened at the beginning) accepts the normal keystroke as for example command-s for save, and the other one does not and gives a warning sound instead. I cannot figure out the difference between the two windows or their controllers. I know it will have to do with the responder chain, but I am left clueless.
Any ideas?
Check to make sure that the window's delegate is set to the window controller, and that the window controller implements -saveDocument: (or whatever action the Save item is connected to).
Windows don't respond to key combinations. Menu items do. In response to being pressed (whether using the mouse, using a key combination, or using Accessibility), the menu item sends its action message down the responder chain.
You get a beep when nothing in the responder chain responds to the action message.
Assuming that this is an NSDocument-based application and you've started Apple's doc-based-app template, the menu item's action is saveDocument:, and the NSDocument object is the object that responds to that message. When your document windows are active, their documents are in the responder chain, so the menu item that sends that action message is enabled. When your third window is active, the document is not in the responder chain; nothing else responds to that message, so the menu item is disabled.
This problem isn't specific to Saveā€”it affects all action messages that should go through to the document object. One important other example is Print: The user will probably mean to print the document, not the third window.
You've probably made this third window a kind of window that exists as a peer to the other windows. Besides this responder-chain problem you're having, the user will also probably not realize that they have left the document; they expect to still be able to do document things. Consider making it a utility panel instead.
If you really do have a good reason to make this window whatever kind of window it is, you'll need to keep the last-active document object in the responder chain when this third window becomes main, while at the same time handling the case where the window becomes main because a document window (possibly the last one) has closed.
Well, it turns out that I implemented the third window in a way where I created it with its controller using initWithNibFile, ran a procedure in the controller and then sent it a [window close] command because I did not want it to appear on the screen yet. That somehow took it out of the document-associated window, no idea why. No I migrated that specific called procedure into the document controller itself, treat the window like the second window and voila, it works again.