Alert callback / io.popen

Is there a way to pause Codea while an alert is showing, or set a callback for when the OK button is pressed?

not that i know…

Check out my alert Objective C add on… You can also modify it by saying codeaViewController.runtime.paused = TRUE (something like that) untill the callback. So, yes, you can get callbacks.

@Zoyt but your solution works only from a compiled app, not from simple native codea, right?

You could create your own alert library in codea that could include this function

@Jmv38 - I think you have your terminology mixed up (or your implications). “Native code” typically implies that you’re referring to Objective C or C. However, I think you mean “native to Lua/Codea.” Also, a “compiled app” is your app after you click the run button in Xcode. The easiest way to explain compiling something is basically when the Objectice C/C/C++ code is converted in assembly, making it (virtually) unreadable.
But to answer your question, yes, my library only works once your app has been exported.
@Coder - That’s what my library does. It allows you to have multiple buttons, set the cancel button name, and have callbacks. Mine pretty much covers the basics of the common alert view.

@Zoyt thanks for your answer (and your intrrpretation of my poor wording was correct).

@Jmv38 - Any time.

You could overload alert() and have it copy draw and replace it with a blank one. When alert is clicked make draw == old draw.

@Briarfox, true - good idea.

That said, callbacks can be used for multiple things, so @Simeon it might be a nice feature to add.

@JakAttak - What’s wrong with my solution?
@Briarfox - I’m not sure what you mean. You can’t overload functions in Lua (well, without writing a lot of extra code). Did you mean override?

o_alert = alert
alert = function(params)
 --hook draw here 
--call original alert
o_alert(params) end

Yeah meant override, typing on my iphone while at dinner :slight_smile:

@Briarfox - All good. :wink:

@Zoyt, I was looking for something that works in Codea, and your solution requires moving to the runtime. That said, that add-on does look nice. I think we should have an alert function like yours built in to Codea.

@JakAttak - I’ve been pushing for that for a while, but eventually made my own.

Didn’t want to start another thread for this, so I thought I’d add to this one:

io.popen doesn’t seem to work. It shows as a function in the editor, but when i try to use it for anything it returns error of 'popen' not supported

What does io.popen have to do with alert callbacks?

Nothing, I just didn’t want to start a new thread. Call this ‘JakAttak’s Miscellaneous Queries’

@JakAttak - File a bug report. Simeon reads those more than he reads the forums, as far as I can tell.

So it is a bug?