Re: $doc.selection is undefined in GWT

2009-06-22 Thread chardina...@boyd.org.nz

I've also been trying to work with selections in GWT and found this
GWT extension:

http://code.google.com/p/rocket-gwt/wiki/Selections

It works with GWT 1.5, I don't know if it has been tested with GWT
1.6. I haven't used it myself

Text selections seems like a fairly important thing, does anyone know
why it is not built into GWT, or if it will be in GWT 2.0?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Google Web Toolkit group.
To post to this group, send email to Google-Web-Toolkit@googlegroups.com
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~--~~~~--~~--~--~---



Re: $doc.selection is undefined in GWT

2009-06-10 Thread bhomass

found the answer.

FF uses $wnd.getSelection().getRangeAt(0)

thanks for all the help.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Google Web Toolkit group.
To post to this group, send email to Google-Web-Toolkit@googlegroups.com
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~--~~~~--~~--~--~---



Re: $doc.selection is undefined in GWT

2009-06-07 Thread bhomass

Thanks for the clarification. I am sure I am close now. but still get
an error. my code is
private native Element getSelectedTextParent() /*-{
var range = null;
  if($wnd.document.selection){
range = $wnd.document.selection.createRange();
  } else if ($wnd.getSelection) {
range = $wnd.getSelection().createRange();
  } else if ($wnd.document.getSelection) {
range = $wnd.document.getSelection().createRange();
  }
return range.parentElement();
//return $doc.selection.createRange().parentElement();
}-*/;

I am getting $wnd.getSelection().createRange is not a function in
FireFox. it seems $wnd.getSelection() is ok, but can not createRange()?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Google Web Toolkit group.
To post to this group, send email to Google-Web-Toolkit@googlegroups.com
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~--~~~~--~~--~--~---



Re: $doc.selection is undefined in GWT

2009-06-06 Thread alexey.dashkev...@gmail.com



On Jun 5, 11:14 pm, bhomass bhom...@gmail.com wrote:
 I looked up some cross browser code. but I am getting different
 results

   if (document.getSelection) {
     var range = document.getSelection().createRange();;
   } else if (document.selection  document.selection.createRange) {
     var range = document.selection.createRange();
   } else {
     var str = Sorry, this is not possible with your browser.;
   }

 I use the range to get the parent Element, range.parentElement();

 originally (using $doc), I get back a div, now I am getting back the
 BODY element.
 document.selection does not seem to be equivalent to $doc.selection,
 even though it removes the browser incompatibility.

 any ideas?


Use script like this one:


public static native String getSelection() /*-{
   var txt = '';
   if ($wnd.getSelection) {
   txt = $wnd.getSelection();
   } else if ($wnd.document.getSelection) {
   txt = $wnd.document.getSelection();
   } else if ($wnd.document.selection) {
   txt = $wnd.document.selection.createRange().text;
   }
   return txt;
}-*/;

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Google Web Toolkit group.
To post to this group, send email to Google-Web-Toolkit@googlegroups.com
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~--~~~~--~~--~--~---



Re: $doc.selection is undefined in GWT

2009-06-05 Thread bhomass

I looked up some cross browser code. but I am getting different
results

  if (document.getSelection) {
var range = document.getSelection().createRange();;
  } else if (document.selection  document.selection.createRange) {
var range = document.selection.createRange();
  } else {
var str = Sorry, this is not possible with your browser.;
  }

I use the range to get the parent Element, range.parentElement();

originally (using $doc), I get back a div, now I am getting back the
BODY element.
document.selection does not seem to be equivalent to $doc.selection,
even though it removes the browser incompatibility.

any ideas?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Google Web Toolkit group.
To post to this group, send email to Google-Web-Toolkit@googlegroups.com
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~--~~~~--~~--~--~---



Re: $doc.selection is undefined in GWT

2009-06-05 Thread Thomas Broyer



On 5 juin, 22:14, bhomass bhom...@gmail.com wrote:
 I looked up some cross browser code. but I am getting different
 results

   if (document.getSelection) {
     var range = document.getSelection().createRange();;
   } else if (document.selection  document.selection.createRange) {
     var range = document.selection.createRange();
   } else {
     var str = Sorry, this is not possible with your browser.;
   }

 I use the range to get the parent Element, range.parentElement();

 originally (using $doc), I get back a div, now I am getting back the
 BODY element.
 document.selection does not seem to be equivalent to $doc.selection,
 even though it removes the browser incompatibility.

 any ideas?

http://code.google.com/webtoolkit/doc/1.6/DevGuideCodingBasics.html#DevGuideJavaScriptNativeInterface

When accessing the browser's window and document objects from JSNI,
you must reference them as $wnd and $doc, respectively. Your compiled
script runs in a nested frame, and $wnd and $doc are automatically
initialized to correctly refer to the host page's window and
document.

'document' above references the iframe's document where your code runs
(i.e. the *.cache.html).
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Google Web Toolkit group.
To post to this group, send email to Google-Web-Toolkit@googlegroups.com
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~--~~~~--~~--~--~---



Re: $doc.selection is undefined in GWT

2009-06-04 Thread Adam T

Hi,

Seems there is something strange going on with search - I answered
your question and can't see the reply either!

The $ before doc is due to GWT loading into an IFrame - GWT ensures
that $doc points to the window's document object (you can read more on
that in the JSNI documentation from GWT home page).

You don't mention which operating system you use, but I believe
document.selection.createRange() only works on IE and not other
browsers, so I guess yuo are developing on Windows, which uses IE as
hosted mode browser and then testing on other browsers in web mode.
Just do a google search for cross-browser
document.selection.createRange() to see how you would do it for Opera,
Safari, Chrom, Firefox etc.

//Adam


On 4 Juni, 02:05, bhomass bhom...@gmail.com wrote:
 I have a native method which uses
 $doc.selection.createRange()

 I am not sure why the $ before doc. I simply copied it from some
 sample code. this method works find when in hosted mode. but after
 compile and called directly from a browser I get the $doc.selection is
 undefined error.

 any one knows what's wrong with this?

 sorry if this is second posting. I posted this question a few days
 ago, but it does not come up in search.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Google Web Toolkit group.
To post to this group, send email to Google-Web-Toolkit@googlegroups.com
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~--~~~~--~~--~--~---



$doc.selection is undefined in GWT

2009-06-03 Thread bhomass

I have a native method which uses
$doc.selection.createRange()

I am not sure why the $ before doc. I simply copied it from some
sample code. this method works find when in hosted mode. but after
compile and called directly from a browser I get the $doc.selection is
undefined error.

any one knows what's wrong with this?

sorry if this is second posting. I posted this question a few days
ago, but it does not come up in search.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Google Web Toolkit group.
To post to this group, send email to Google-Web-Toolkit@googlegroups.com
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~--~~~~--~~--~--~---