I’ve searched and I didn’t see an answer to my problem (I suspect I saw my problem, but it wasn’t well defined or answered).
I have a webview in a panel. It successfully loads a page in awake from nib, but after that it gets funky. It doesn’t update the web page contents until I grab and drag a draggable element (a link or graphic). It doesn’t matter if I navigate to a link in the webview or change the connected text field. The sample code minibrowser works, albeit slowly, so I suspect it’s not the framework. I’m confused. Maybe it doesn’t like my panel as a parent?
I’d like to update the URLText field when someone clicks inside the page (and other things, but crawling first, then walking).
The system is 10.4.9. My code (found here!, thank you!) is as follows:
on clicked theObject --> the buttons, for use later...
if name of theObject is "CancelButton" then
close panel window "WebPanel" with result -1
else if name of theObject is "WebUploadButton" then
close panel window "WebPanel" with result 1
end if
end clicked
on end editing theObject --> attached to text field "URLText"
set MyPage to contents of text field "URLText" of window "WebPanel"
LoadWebPage(MyPage)
tell window "WebPanel" to set first responder to view "Webview"
end end editing
on LoadWebPage(PageURL)
try
set contents of text field "URLText" of window "WebPanel" to PageURL
set webView to view "webView" of window "WebPanel"
--call method "setEditable:" of (webView) with parameters {true}
set URLWithString to call method "URLWithString:" of class "NSURL" with parameter PageURL
set requestWithURL to call method "requestWithURL:" of class "NSURLRequest" with parameter URLWithString
set mainframe to call method "mainFrame" of object webView
call method "loadRequest:" of mainframe with parameter requestWithURL
on error theError
display dialog "Couldn't load web page:" & theError
end try
end LoadWebPage
on opened theObject --> Attached to the window
set LastURL to "http://www.whiterose.org/michael/"
--display dialog LastURL
set contents of text field "URLText" of window "WebPanel" to LastURL
tell window "WebPanel" to set first responder to view "Webview"
LoadWebPage(LastURL)
end opened
on awake from nib theObject
set LastURL to "http://www.whiterose.org/"
--display dialog LastURL
set contents of text field "URLText" of window "WebPanel" to LastURL
tell window "WebPanel" to set first responder to view "Webview"
LoadWebPage(LastURL)
end awake from nib