Dialog Plugin: HTMLTip problem

View: New views
2 Messages — Rating Filter:   Alert me  

Dialog Plugin: HTMLTip problem

by Hans-Jörg Bibiko :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hi,

some days ago I downloaded the Ciarán Walsh's code for the new HTMLTip.
I compiled it and I had the problem that:

[webView stringByEvaluatingJavaScriptFromString:@"return  
document.body.offsetHeight + document.body.offsetTop;"];

returns always (null) regardless of the JavaScript, meaning I 'saw'  
the tooltip with the content size 0,0.
If I set height and width by hand the dialog runs fine.

Then I tried it out on my good old G4 iMac and it works perfectly !?

The only difference between both Macs is Safari. On my G4 I run  
Safari 2.0.4, and on my new Mac I run Safari 3.0.3. After reading a  
bit I guess that the problem only occurs if one has installed Safari  
3.x. With the new Safari version it also comes a new WebKit version.

Up to now I didn't find a solution for that.

Any ideas?


Cheers,

Hans_______________________________________________
textmate-plugins mailing list
textmate-plugins@...
http://lists.macromates.com/mailman/listinfo/textmate-plugins

Re: Dialog Plugin: HTMLTip problem

by Hans-Jörg Bibiko :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On 24 Sep 2007, at 15:10, Hans-Joerg Bibiko wrote:

>
> Hi,
>
> some days ago I downloaded the Ciarán Walsh's code for the new  
> HTMLTip.
> I compiled it and I had the problem that:
>
> [webView stringByEvaluatingJavaScriptFromString:@"return  
> document.body.offsetHeight + document.body.offsetTop;"];
>

I fixed this for Safari 3.0.3!

Instead of using 'stringByEvaluatingJavaScriptFromString' I use now  
'[[webView windowScriptObject] evaluateWebScript]' and it works.

- (void)sizeToContent
{
        NSPoint pos = NSMakePoint([[self window] frame].origin.x, [[self  
window] frame].origin.y + [[self window] frame].size.height);
// int height  = [[webView  
stringByEvaluatingJavaScriptFromString:@"return  
document.body.offsetHeight + document.body.offsetTop;"] intValue];
// int width   = [[webView  
stringByEvaluatingJavaScriptFromString:@"return  
document.body.offsetWidth + document.body.offsetLeft;"] intValue];
        id wsc = [webView windowScriptObject];
        int height  = [[wsc evaluateWebScript:@"document.body.offsetHeight +  
document.body.offsetTop;"] intValue];
        int width   = [[wsc evaluateWebScript:@"document.body.offsetWidth +  
document.body.offsetLeft;"] intValue];
        [[self window] setContentSize:NSMakeSize(width, height)];
....


--Hans_______________________________________________
textmate-plugins mailing list
textmate-plugins@...
http://lists.macromates.com/mailman/listinfo/textmate-plugins