dragdata[html], clipboarddata[html] question

Jan Schenkel janschenkel at yahoo.com
Thu Jul 24 03:30:03 EDT 2003


--- Ron <rbarber at yhb.att.ne.jp> wrote:
> Hi
> 
> I wanted to confirm this or be told it was expected
> behavior before I bug
> report it.
> 
> The problem is that text dragged or copied from a
> fld will not maintain the
> textfont property correctly when the fld has the
> textfont set by script.
> Thus the dragdata[html] [rtf] and
> clipboarddata[html] [rtf] do not report
> the correct data either.
> 
> To reproduce this:
> set the textfont of fld 1 to "not the default font
> of the stack"
> set the text to mytext
> 
> Now, select some text and drag it to another fld, or
> copy and paste it. The
> resulting text is in the default font of the stack,
> not the textfont
> reported of the original fld.
> 
> Now, select all in fld 1. Explicitly set the
> textfont from the menu. Then
> drag or copy and paste. The textfont is correctly
> maintained (and reported
> in dragdata and clipboarddata)
> 
> This is on OS 9 w/ RR 2.0.1
> 
> Is this expected? and does it happen on other OS's?
> 
> Thanks
> Ron
> 
> ps is there a work around?
> 

Hi Ron,

I would say it behaves as expected : the rendering
hierarchy of Revolution checks the font settings all
the way back to the mainStack's textFont, textSize and
textStyle properties to ultimately decide how text
will look.
Thus when you set the htmlText of field 1 to the
htmlText of field 2, and the textFont setting in field
1 is different from the textFont setting of field 2 ;
it will now be shown with the textFont of field 1,
except in those spots where the textFont was set at
chunk level.

This approach has its advantages and disadvantages :
when you copy text from field 1 to field 2, you don't
need to adapt the font. But in cases where you really
want the font, it's a different story.

As for a workaround, that gets trickier. You could try
to trap the 'copyKey' and 'dragStart' messages and
change the htmlText of your field before the engine
fills up the clipboardData or dragData.
You would do something like this [UNTESTED]:

on dragStart
  put the HTMLText of the target into tHTMLText
  put "<p><font face=" & quote & \
      the effective textFont of the target & \
      quote & ">") into tPReplacement
  replace "<p>" with tPReplacement in tHTMLText
  replace "</p>" with "</font></p>" in tHTMLText
  set the htmlText of the target to tHTMLText
  pass dragStart
end dragStart

Of course you'd still have to check if the target is a
field, and you may have to save the selectedChunk and
reselect it, and you may want to only replace those
"<p>" and "</p>" tags where there's no font-tag in
sight (regular expressions, anyone?) but the idea
should work, I think.

Hope this helped,

Jan Schenkel.

=====
"As we grow older, we grow both wiser and more foolish at the same time."  (La Rochefoucauld)

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com



More information about the use-livecode mailing list