textselection

How to get coordinates (CGRect) for the selected text in UIWebView?

爱⌒轻易说出口 提交于 2019-11-28 21:26:12
I have simple UIWebView with loaded html. I want to show the PopoverView pointed to the selected text. I can get the menuFrame of the UIMenuController and use its rect, but the result isn't as accurate at the corners of the screen as I need. I can calculate the screen size and get menuFrame rect and then I can suppose where the selection may be found, but I want exactly know where is the selected text. Is it generally possible? hwaxxer You can use the javascript function getBoundingClientRect() on the range object of the selected text. This is how I do it: function getRectForSelectedText() {

IOS: Text Selection in WKWebView (WKSelectionGranularityCharacter)

别说谁变了你拦得住时间么 提交于 2019-11-28 21:08:12
I've got an app that uses a web view where text can be selected. It's long been an annoyance that you can't select text across a block boundary in UIWebView. WKWebView seems to fix this with a property on its configuration: selectionGranularity . One of the possible values is WKSelectionGranularityCharacter : Selection endpoints can be placed at any character boundary. Sounds great! Exactly what I need. Except that when I set that in my web view, I often can no longer select text at all. What is going on? Is there something else I need to set? Has anyone figured this out? Update: I've figured

How to create tooltip over text selection without wrapping?

感情迁移 提交于 2019-11-28 16:45:46
My end goal is to create a tooltip over a text selection. The user will then be able to interact with the tooltip similar to . Please note that I was able to accomplish this by wrapping selected text in a tag and then creating the tooltip on it however this is no longer an option for me due to some other requirements and functionality issues. If you notice in the image above in element inspector, the selected text is not wrapped in any kind of tag, the tooltip is just created over the selection. I have already looked at this and it will not work for me because mouse position may not be the

Maintain Text Selection When Using DIV as a button

元气小坏坏 提交于 2019-11-28 08:46:30
问题 Maybe this is a browser related issue? I'm on Chrome at the moment... What I'm trying to accomplish is allow the user to save text that they've selected (highlighted) on the page with their cursor. I've got the javascript/jQuery/ajax all setup...and it works like a charm when I'm testing it via the console. i.e. - I select some text and then run this command. alert(getSelected()); To which I get an alert popup with the selected characters. ...so it works in theory. HOWEVER - When I want to

How to prevent the double-click select text in Javascript

百般思念 提交于 2019-11-28 08:01:31
问题 Say I have an ul ( li ) list in the page: <ul> <li>xxx<li> <li>xxx<li> </ul> The element li are clickable and double-clickable, they are attached with these events, and I return false in both of them. $('ul li').on('click',function(){ //do what I want return false; }).on('dblclick',function(){ //do what I want return false; }); But when the user double-clicks the element, the text inside the li will be selected. How can this be prevented? Update: Solved now,I use the following code with the

How to disable cursor positioning and text selection in an EditText? (Android)

风格不统一 提交于 2019-11-28 07:14:55
I'm searching for a way to prevent the user from moving the cursor position anywhere. The cursor should always stay at the end of the current EditText value. In addition to that the user should not be able to select anything in the EditText. Do you have any idea how to realize that in Android using an EditText? To clarify: the user should be able to insert text, but only at the end. I had the same problem. This ended up working for me: public class CustomEditText extends EditText { @Override public void onSelectionChanged(int start, int end) { CharSequence text = getText(); if (text != null) {

How to get the selected text in textarea using jQuery in Internet Explorer 7?

梦想与她 提交于 2019-11-28 05:14:56
问题 I tried the jquery-fieldselection plugin to get the selected text in textarea. It works fine in Firefox and Chrome, but not in Internet Explorer 7. I use the getSelection() method like this: textarea.getSelection(); When the text within the textarea is 12345 , and all this text is selected, Firefox and Chrome returns: start: 0 // Correct! end: 5 while Internet Explorer 7 returns: start: 5 // Why ?? end: 5 I'm looking for a cross browser solution using jQuery. 回答1: just took a look a

How to use the new Android M feature of “Text Selection” to be offered from outside of your app?

蹲街弑〆低调 提交于 2019-11-28 04:46:11
Background Android M presents a new way to handle selected text (link here ), even from outside of your app . Text selection can be handled as such: I know it's possible to handle the selected text from outside the app, because if I go to the web browser (or any other place that allows text selection), I can see that I can use the "API demos" app to handle the selected text. The problem I can't see a lot of information about how to do it. The question What should be added in code (and manifest) to be able to handle the selected text from outside the app ? Is it possible to limit the selection

Why does the CSS3 pseudo ::selection not change the color for all parts?

为君一笑 提交于 2019-11-28 00:02:23
Why does the CSS3 pseudo-element selection not change all parts of the highlight? As you can see in this screenshot I have selected part of the page, and parts of the selection are the default bright blue color: This is the CSS that I'm using, it is at the top of my CSS file: ::selection { background: #3B3B3B; color: #fff; } ::-moz-selection { background: #3B3B3B; color: #fff; } It seems like the highlight for inputs (text, checkboxes, etc.) and white space does not change. Does anyone know why this is, and is there a way to change it for every part of the page so the highlight color is

Text selection in div(contenteditable) when double click

北战南征 提交于 2019-11-27 23:15:10
I have div with some text and contenteditable="true". When I single click on this div - works some my scripts, it is not very important. And when I double click on this div - need to edit text in div. Edit text need to be only after double click, not after single. And very imortant, when I double click on div - caret need stay under mouse cursor. No need selection text. I found some script for single/double. But have problem. When I double click on div - text are selection. Selection no need. Need editor caret where I clicked. I do not understand how. http://jsfiddle.net/X6auM/ Tim Down Every