macMikey / LCB-missing-manual

I'm trying to learn LCB, again, but the docs are thin.
MIT License
4 stars 4 forks source link

message box #14

Closed macMikey closed 2 years ago

macMikey commented 2 years ago

this does not work:

private handler Message ( in pPrompt as String, in pBeforeAfterInto as String ) returns nothing
    execute script "put \q" & pPrompt & "\q" && pBeforeAfterInto && "msg"
end handler

I get Script access not allowed

bwmilby commented 2 years ago

do you have use com.livecode.engine in the code?

macMikey commented 2 years ago

yes. I'm working on NavRAD, so it looks like it's got all the USE lines in it.

use com.livecode.canvas
use com.livecode.widget
use com.livecode.engine
use com.livecode.library.iconsvg
use com.livecode.library.widgetutils
bwmilby commented 2 years ago

Ok, the error is from the IDE and not the compiler. I'm getting the same thing.

bwmilby commented 2 years ago

This issue is where/when you are attempting to use script access. Where in the flow of the widget creation are you calling that handler?

Note: An error is thrown if this syntax is used in a context where access to script objects is not allowed.

Not sure what that exactly means though.

macMikey commented 2 years ago

In OnLoad() to debug the value of a property, since I don't think we have a real debugger in lcb So I took that one out, and I have one in CalculateIconRects(), which is called in OnCreate(), but that's also throwing the error, so I'm guessing it's still too early.

bwmilby commented 2 years ago

Yes, I would infer that until the widget is fully created that you can’t use the script. The message is going to the script object.