Cocoa and UserCancelled

I make heavy use of UserCancelled and found that it’s not working in Cocoa. I checked the LR and see that it is not compatible with Cocoa. But in Feedback I found #18164, which reports and issue with Cocoa and UserCancelled that Joe listed it as fixed and waiting for verification on January 27, 2013. From reading the comments, I can’t tell if the fix was for WIndows or Cocoa. So my question is, should UserCancelled be working on Cocoa? And if not, is there a workaround (presumably via a declare)? I suppose it would be possible to monitor the keydown event, but there are situations where that’s not easily do-able.

The fix was for both Windows and Cocoa. I assume you’re saying that it’s not working in 2013r1b16?

Thanks for confirming that. It’s behaving oddly in my project’s code (where it worked well in Carbon). But in a simple example I can’t reproduce the problem. Now that I know it should work, I’ll delve into the code and see if it’s failing under some special circumstance, or if it’s some other issue.

In 2013r1b16 I have a timer with this action event

if UserCancelled then
me.mode = 0
end if

When it’s running pressing Command-. does not invoke the code in the loop. I’ll see if I can make a simple example that shows this (probably not, but I’ll try).

Hm, I made another post yesterday that didn’t seem to make it. Here it is again. I can reproduce the problem with a simple example. Create a new window with a timer, mode 2, with this action event:

if UserCancelled then
end if

Command-. never breaks into the loop contents. Is the cancelled event not passed back to code in timers?

Report on FB and attach your sample.

The entire example is above. I’ll file a report if it in fact should work. I tried in Carbon and it didn’t work there, either, so perhaps this is not a bug but a known limitation of timers.

You expected a different result, so, for me, it deserves further investigation, and further investigations starts only by feedback reports.

UserCancelled looks at the event queue for an escape or cmd-period. Since your main event loop is running, those events get dequeued and processed, so by the time you call UserCancelled they have been processed.

Ricardo, Not to pick on you, but sometimes, people would like to use the forum to get some insight into a problem before making a Feedback issue of it. Everyone in the beta test knows how feedback works.

Hm, let’s say I’ve send an HTTPSocket get asynchronously and have put up a UI indicator, but while waiting for a response want to cancel. How would I do that with UserCancelled if a timer can’t be used? I’ve tried looking for Command-. in the main window’s keyDown event but it is never received (gobbled up by UserCancelled, I assume).

I do the same Brad. But I can’t assume everyone knows everything. My point was: If what I told, for that person, wasn’t known, it was a good advice, and in case of my words “raining over the sea”, it does not matter. The scenario is always positive or neutral, never negative.

It pollutes the flow of the conversation. Some of these things don’t need to be reported or prematurely reported. They need information gathered. Please let that happen.

Agree with Brad. And Joe was already engaged in this thread…