cursor-position

contentEditable cursor's parent element

偶尔善良 提交于 2019-12-02 04:53:45
问题 I have a contentEditable HTML element. I would like to get the cursor's parent element. For example, if the cursor is inside a table cell, I would like to display some controls for editing the table. Is this possible? Or am I going to track all key and mousepresses? 回答1: Example using parentNode: document.getElementById('editable').onclick = function () { alert(this.parentNode.id); } 来源: https://stackoverflow.com/questions/7770404/contenteditable-cursors-parent-element

contentEditable cursor's parent element

蹲街弑〆低调 提交于 2019-12-02 02:52:45
I have a contentEditable HTML element. I would like to get the cursor's parent element. For example, if the cursor is inside a table cell, I would like to display some controls for editing the table. Is this possible? Or am I going to track all key and mousepresses? Example using parentNode : document.getElementById('editable').onclick = function () { alert(this.parentNode.id); } 来源: https://stackoverflow.com/questions/7770404/contenteditable-cursors-parent-element

Make Object Follow Mouse On MouseDown and “Stick” On MouseUp

这一生的挚爱 提交于 2019-12-02 01:27:14
I'm working with a project that is WPF and VB.net. I want to visually simulate "dragging" an object (though I do not want to use standard drag and drop for reason of purpose). Basically, I have a label object that, on its MouseDown event, I want it to follow the mouse cursor inside a 640x480 solid-size grid (but not outside of it!). Mind you, this grid is centered inside a full-screen window. Again, the object should not follow the mouse outside of the grid (I'm guessing a "ClipToBounds = True" here) Then, on the label's MouseUp event, I want it to either stay in its current position or return

Listview with TextView and Button. RowId of the clicked button

拟墨画扇 提交于 2019-12-01 23:35:40
问题 I hava a listview like the following. The text in the TextView comes from a database. ------------------------- TextView Button ------------------------- When I click on the button, I want to show the text in the TextView of this row in a Toast. My question is the following: When I click on the button, I am showing the text of the row, which is selected by the cursor. I am not showing the text of the row where the button is. I know the problem is the mCursor variable. I don't know how to fix

Listview with TextView and Button. RowId of the clicked button

牧云@^-^@ 提交于 2019-12-01 22:39:48
I hava a listview like the following. The text in the TextView comes from a database. ------------------------- TextView Button ------------------------- When I click on the button, I want to show the text in the TextView of this row in a Toast. My question is the following: When I click on the button, I am showing the text of the row, which is selected by the cursor. I am not showing the text of the row where the button is. I know the problem is the mCursor variable. I don't know how to fix it. Has anybody an idea? Here is my ModulCursorAdapter: public class ModuleCursorAdapter extends

tinyMCE - get content up to cursor position

无人久伴 提交于 2019-12-01 21:00:44
I am making a little word prediction plugin for tinyMCE and need to extract a bit of text and later insert text from a list of predicted words. The insertion should be no problem, as I know where the cursor is and can use the mceInsertContent command. Getting the text for the prediction however... I need to extract a subset of the text ending at the letter immediately before the cursor position and starting at, well, the start of the text. I can strip HTML tags myself if neccessary, but I prefer letting tinyMCE do it if possible. I was thinking of doing it like this: Insert bookmark at current

Get cursor-position in contenteditable div

喜欢而已 提交于 2019-12-01 13:01:05
I found the following code here on SO to get the position of the cursor of a contenteditable div, however it always returns 0. The function that should retrieve the position: new function($) { $.fn.getCursorPosition = function() { var pos = 0; var input = $(this).get(0); // IE Support if (document.selection) { input.focus(); var sel = document.selection.createRange(); var selLen = document.selection.createRange().text.length; sel.moveStart('character', -input.value.length); pos = sel.text.length - selLen; } // Firefox support else if (input.selectionStart || input.selectionStart == '0') pos =

JavaScript: get cursor position in contenteditable div

天大地大妈咪最大 提交于 2019-12-01 11:34:04
问题 I am pretty new to JavaScript and hope someone here can help me with the following: Primarily looking for a solution in IE 8 - if it can cover other browsers / versions even better. I have a page with only one contenteditable div that is created dynamically and contains both text and HTML tags. On the page I want to add a button that inserts certain text at the cursor position into this div. So far I have the following code which works fine as long as I select a text in the div but if I just

Set caret position in contenteditable div

依然范特西╮ 提交于 2019-12-01 10:47:28
问题 Intro When editing the content of a contenteditable DOM Object, different browsers have different behaviours. For instance, Firefox 18.0 creates a new paragraph ( <p> ) or a line break <br/> in some instances while Chrome 24 creates a <div> . In order to cope with this, I'm listening to the DOMNodeInserted event and replacing the new inserted nodes with p tags. Problem The problem is placing the caret in place. I've read tons of posts in SO regarding this same subject but none of the provided

How to display coordinates and use ginput

折月煮酒 提交于 2019-12-01 05:59:20
I cannot seem to get my image to display the coordinates of my mouse cursor, and also use ginput to store points at the same time. I currently am trying the following: MriHotrod = imread('Image.bmp'); Fig = figure('Name','BobDole'),... imshow(Image, 'InitialMagnification', 250) axis on impixelinfo Image_1 = ginput(4) close BobDole The ginput still works, but the impixelinfo stays constant Pixel Info = (X, Y) Pixel Value I am aware of some methods of getting around this, but they involve functions. This seems like a rather simple problem that can avoid the use of functions. If you type edit