Search Results

Search found 143 results on 6 pages for 'caret'.

Page 3/6 | < Previous Page | 1 2 3 4 5 6  | Next Page >

  • Execute code at specific intervals, only once?

    - by Mathias Lykkegaard Lorenzen
    I am having an issue with XNA, where I want to execute some code in my Update method, but only at a given interval, and only once. I would like to avoid booleans to check if I've already called it once, if possible. My code is here: if ((gameTime.TotalGameTime.TotalMilliseconds % 500) == 0) { Caret.Visible = !Caret.Visible; } As you may have guessed, it's for a TextBox control, to animate the caret between invisible and visible states. I just have reason to believe that it is called twice or maybe even 3 times in a single update-call, which is bad, and makes it look unstable and jumpy.

    Read the article

  • How to keep track of TextPointer in WPF RichTextBox?

    - by Alan Spark
    I'm trying to get my head around the TextPointer class in a WPF RichTextBox. I would like to be able to keep track of them so that I can associate information with areas in the text. I am currently working with a very simple example to try and figure out what is going on. In the PreviewKeyDown event I am storing the caret position and then in the PreviewKeyUp event I am creating a TextRange based on the before and after caret positions. Here is a code sample that illustrates what I am trying to do: // The caret position before typing private TextPointer caretBefore = null; private void rtbTest_PreviewKeyDown(object sender, KeyEventArgs e) { // Store caret position caretBefore = rtbTest.CaretPosition; } private void rtbTest_PreviewKeyUp(object sender, KeyEventArgs e) { // Get text between before and after caret positions TextRange tr = new TextRange(caretBefore, rtbTest.CaretPosition); MessageBox.Show(tr.Text); } The problem is that the text that I get is blank. For example, if I type the character 'a' then I would expect to find the text "a" in the TextRange. Does anyone know what is going wrong? It could be something very simple but I've spent an afternoon getting nowhere. I am trying to embrace the new WPF technology but find that the RichTextBox in particular is so complicated that it makes even doing simple things like this difficult. If anyone has any links that do a good job of explaining the TextPointer, I would appreciate it if you can let me know.

    Read the article

  • Firefox 3.03 and contentEditable

    - by Ash
    I'm using the contentEditable attribute on a DIV element in Firefox 3.03. Setting it to true allows me to edit the text content of the DIV, as expected. Then, when I set contentEditable to "false", the div is no longer editable, also as expected. However the flashing caret (text input cursor) remains visible even though the text is no longer editable. The caret is now also visible when I click on most other text in the same page, even in normal text paragraphs. Has anyone seen this before? Is there any way to force the caret hidden? (When I either resize the browser or click within another application, and come back, the caret magically disappears.)

    Read the article

  • error - inherited class field undeclared according to g++

    - by infoholic_anonymous
    I have a code that has the following logic. g++ gives me the error that I have not declared n in my iterator2. What could be wrong? template <typename T> class List{ template <typename TT> class Node; Node<T> *head; /* (...) */ template <bool D> class iterator1{ protected: Node<T> n; public: iterator1( Node<T> *nn ) { n = nn } /* (...) */ }; template <bool D> class iterator2 : public iterator1<D>{ public: iterator2( Node<T> *nn ) : iterator1<D>( nn ) {} void fun( Node<T> *nn ) { n = nn; } /* (...) */ }; }; EDIT : I attach the actual header file. iterator1 would be iterable_frame and iterator2 - switchable_frame. #ifndef LST_H #define LST_H template <typename T> class List { public: template <typename TT> class Node; private: Node<T> *head; public: List() { head = new Node<T>; } ~List() { empty_list(); delete head; } List( const List &l ); inline bool is_empty() const { return head->next[0] == head; } void empty_list(); template <bool DIM> class iterable_frame { protected: Node<T> *head; Node<T> **caret; public: iterable_frame( const List &l ) { head = *(caret = &l.head); } iterable_frame( const iterable_frame &i ) { head = *(caret = i.caret); } ~iterable_frame() {} /* (...) - a few methods follow */ template <bool _DIM> friend class supervised_frame; }; template <bool DIM> class switchable_frame : public iterable_frame<DIM> { Node<T> *main_head; public: switchable_frame( const List& l ) : iterable_frame<DIM>(l) { main_head = head; } inline bool next_frame() { caret = &head->next[!DIM]; head = *caret; return head != main_head; } }; template <bool DIM> class supervised_frame { iterable_frame<DIM> sentinels; iterable_frame<DIM> cells; public: supervised_frame( const List &l ) : sentinels(l), cells(l) {} ~supervised_frame() {} /* (...) - a few methods follow */ }; template <typename TT> class Node { unsigned index[2]; TT num; Node<TT> *next[2]; public: Node( unsigned x = 0, unsigned y = 0 ) { index[0]=x; index[1]=y; next[0] = this; next[1] = this; } Node( unsigned x, unsigned y, TT d ) { index[0]=x; index[1]=y; num=d; next[0] = this; next[1] = this; } Node( const Node &n ) { index[0] = n.index[0]; index[1] = n.index[1]; num = n.num; next[0] = next[1] = this; } ~Node() {} friend class List; }; }; #include "List.cpp" #endif the exact error log is the following: In file included from main.cpp:1: List.h: In member function ‘bool List<T>::switchable_frame<DIM>::next_frame()’: List.h:77: error: ‘caret’ was not declared in this scope

    Read the article

  • How to make Chrome spell check the whole text field?

    - by Laurent
    On Firefox, whenever a word is incorrect in a text field, it is underlined in red. Chrome does the same but the difference is that it underlines in red only when I move the caret over the word. So if I want to spell check the whole text field, I have to move the caret from the beginning to the end of the text field. Is it possible to make Chrome works more like Firefox and spell check the entire text field automatically?

    Read the article

  • In MSWORD How can I make it so that while doing repeated searches, the document scrolls in a reasona

    - by user289444
    Typically in MSWord if a search result is off the page, the document window will move down to dispaly the result, already selected - but only just barely showing it. Is there a way to make the display move more, so that the result is (for example) centered instead? This is possible in other text editors such as SciTE using caret.policy.yslop=1 caret.policy.lines=5

    Read the article

  • NavigateBackward in Vim?

    - by vexe
    So Ctrl-o works only with jumps and has a history, '' gets you back to your last position regardless of how you ended up there (jumping, navigating, etc) but there's no history for it. What I'm looking for is the best of those two worlds, something like Visual studio's NavigateBackward. Ctrl-o is good but a lot of the times it takes me back to positions I wouldn't expect, jumping is not the only way I navigate... Is there a built-in command/way in vim that does this? if not, is there a plugin for it? if not, I have no problem writing a plugin myself, I know how to set/get the caret position, but I looked at the autocmd-events and couldn't find anything that fires when the caret changes position. How would I go about detecting the 'change' of the caret position? Thanks.

    Read the article

  • Can't change Emacs's default indentation between HTML tags

    - by janoChen
    I'm confused about the Emacs indentation paradigm. I have this in my .emacs file: (setq-default tab-width 4) If I press TAB in the following situation <ul> (caret) </ul> it end up like this <ul> (caret) </ul> (with 2 spaces indentation between the HTML tags.) It should end up like this: <ul> (caret) </ul> I tried everything: (setq-default tab-width 4) (setq-default indent-tabs-mode t) (setq tab-stop-list '(4 8 12 16)) I've set every possible Emacs setting about indentation to 4 but that 2 space indentation is still there. Any suggestions?

    Read the article

  • RichTextBox CaretPosition physical location

    - by Jan Kratochvil
    Hi, I'm using a RichTextBox class to make some automatic text formatting. And mz question is, how do I get the RichTextBox to put some string immediately after the caret. When I use RichTextBox.CaretPosition.InsertTextInRun("some string") the text is inserted after the current logical block, but I need to be insterted immediately after the caret, in the middle of a Run block. I hope it's clear, thx very much.

    Read the article

  • textarea.selectionStart in IE

    - by kayahr
    With this code I can check the caret position in a textarea in firefox: document.getElementById(("myTextArea").selectionStart This doesn't work in IE 8. How can I get the caret position in IE 8?

    Read the article

  • Contenteditable text editor and cursor position

    - by Cal S
    How can I (using jquery or other) insert html at the cursor/caret position of my contenteditable div: <div contenteditable="true">Hello world</div> For example, if the cursor/caret was between "hello" and "world" and the user then clicked a button, eg "insert image", then using javascript, something like <img src=etc etc> would be inserted between "hello" and "world". I hope I've made this clear =S Example code would be greatly appreciated, thanks a lot!

    Read the article

  • In MSWORD How can I make it so that while doing repeated searches, the document scrolls in a reasona

    - by user289444
    Typically in MSWord if a search result is off the page, the document window will move down to dispaly the result, already selected - but only just barely showing it. Is there a way to make the display move more, so that the result is (for example) centered instead? This is possible in other text editors such as SciTE using caret.policy.yslop=1 caret.policy.lines=5

    Read the article

  • Advice welcomed on creating my own Swing component

    - by Toto
    Recently I asked which was the best Swing component to bind to a BigDecimal variable (with some particular editing properties). It turns out that none of the standard Swing components suit me completely, nor did the third-party Swing component libraries I've found out there. So I’ve decided to create my own Swing component. Component description: I want to extend JTextField or JFormattedTextField, so my new component can be easily bound to a BigDecimal variable. The component will have customizable scale and length properties. Behavior: When the component is drawn, it shows only the decimal point and space for scale digits to its right. When the component receives focus the caret should be positioned left to the decimal point. As the user types numbers (any other character is ignored) they appear to the left of the caret, only length – scale numbers are accepted, any other number typed is ignored as the integer portion is full. Any time the user types the decimal point the caret moves to the right side of the decimal point. The following numbers typed are shown in the decimal part, only scale numbers are considered any other number typed is ignored as the decimal portion is full. Additionally, thousand separators should appear as the user types numbers left to the decimal point. Invoking a getValue() method on the component should yield the BigDecimal representing the number just entered. I’ve never created my own Swing component; I’ve barely used the standard ones. So I would appreciate any good tutorial/info/tip on creating the component described. This is the only thing I've got so far. Thanks in advance.

    Read the article

  • Firefox: non-Vimperator way to do mouseless browsing?

    - by Peter Mortensen
    Is it possible to do efficient browsing with Firefox using only the keyboard (like in Opera)? By efficient I mean something faster than using TAB - this takes far too long. The arrow keys should be for navigation (in Opera it is Shift + arrow key). It can done with the Vimperator add-on, but isn't there a simpler way? Update 2: the closest to Opera's way is to enable caret navigation (F7 toggles this mode). It doesn't jump between links so it is a little bit slower, but the normal navigation (arrow keys, page up, page down, etc.) works and the focus/caret/cursor follows (in contrast to a text editor for page up/down). And text can be selected and copied like in a text editor. The biggest drawback is that in practice it is necessary to switch in and out of caret mode. And there is no indication of which mode is currently active. Update 1: a work-around (proposed by several but is not really what I am looking for) can be used if 3 settings are changed (to make it practical). After these changes the first few letters of a link text can be typed and that link will selected so pressing Enter will open it. Using the work-around the screen will jump around if it is a long page as it does not restrict itself to the current visible page, but it is usable. First settings change: menu Tools/Options/Advanced/tab General/Accessibility/Search for text when I start typing Turn this option on. Second settings change: set option to only go to links; in address bar enter: about:config followed by Enter. Then: press "I'll be careful, I promise", find the line accessibility.typeaheadfind.linksonly, select it and change the value to True by either hitting Enter or Shift+F10/Toggle (accessibility.typeaheadfind.linksonly is on line 11 when I tried). Third settings change: turn off case-sensitivity. Set accessibility.typeaheadfind.casesensitive to 0 (same procedure as for accessibility.typeaheadfind.linksonly, see above. When Enter is pressed a dialog box will appear with the current value. Type 0 and press Enter). To use: type some part of the link. If there are several possibilities use Ctrl+G (or F3) to jump between them. Use Ctrl+Enter to open in a new tab. Platform: Firefox 3.0.6, Windows XP 64 bit SP2.

    Read the article

  • Swing: Scroll to bottom of JScrollPane, conditionally on current viewport location

    - by I82Much
    Hi all, I am attempting to mimic the functionality of Adium and most other chat clients I've seen, wherein the scrollbars advance to the bottom when new messages come in, but only if you're already there. In other words, if you've scrolled a few lines up and are reading, when a new message comes in it won't jump your position to the bottom of the screen; that would be annoying. But if you're scrolled to the bottom, the program rightly assumes that you want to see the most recent messages at all times, and so auto-scrolls accordingly. I have had a bear of a time trying to mimic this; the platform seems to fight this behavior at all costs. The best I can do is as follows: In constructor: JTextArea chatArea = new JTextArea(); JScrollPane chatAreaScrollPane = new JScrollPane(chatArea); // We will manually handle advancing chat window DefaultCaret caret = (DefaultCaret) chatArea.getCaret(); caret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE); In method that handles new text coming in: boolean atBottom = isViewAtBottom(); // Append the text using styles etc to the chatArea if (atBottom) { scrollViewportToBottom(); } public boolean isAtBottom() { // Is the last line of text the last line of text visible? Adjustable sb = chatAreaScrollPane.getVerticalScrollBar(); int val = sb.getValue(); int lowest = val + sb.getVisibleAmount(); int maxVal = sb.getMaximum(); boolean atBottom = maxVal == lowest; return atBottom; } private void scrollToBottom() { chatArea.setCaretPosition(chatArea.getDocument().getLength()); } Now, this works, but it's janky and not ideal for two reasons. By setting the caret position, whatever selection the user may have in the chat area is erased. I can imagine this would be very irritating if he's attempting to copy/paste. Since the advancement of the scroll pane occurs after the text is inserted, there is a split second where the scrollbar is in the wrong position, and then it visually jumps towards the end. This is not ideal. Before you ask, yes I've read this blog post on Text Area Scrolling, but the default scroll to bottom behavior is not what I want. Other related (but to my mind, not completely helpful in this regard) questions: Setting scroll bar on a jscrollpane Making a JScrollPane automatically scroll all the way down. Any help in this regard would be very much appreciated.

    Read the article

  • Swing: Scroll to bottom of JScrollPane, conditional on current viewport location

    - by I82Much
    Hi all, I am attempting to mimic the functionality of Adium and most other chat clients I've seen, wherein the scrollbars advance to the bottom when new messages come in, but only if you're already there. In other words, if you've scrolled a few lines up and are reading, when a new message comes in it won't jump your position to the bottom of the screen; that would be annoying. But if you're scrolled to the bottom, the program rightly assumes that you want to see the most recent messages at all times, and so auto-scrolls accordingly. I have had a bear of a time trying to mimic this; the platform seems to fight this behavior at all costs. The best I can do is as follows: In constructor: JTextArea chatArea = new JTextArea(); JScrollPane chatAreaScrollPane = new JScrollPane(chatArea); // We will manually handle advancing chat window DefaultCaret caret = (DefaultCaret) chatArea.getCaret(); caret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE); In method that handles new text coming in: boolean atBottom = isViewAtBottom(); // Append the text using styles etc to the chatArea if (atBottom) { scrollViewportToBottom(); } public boolean isAtBottom() { // Is the last line of text the last line of text visible? Adjustable sb = chatAreaScrollPane.getVerticalScrollBar(); int val = sb.getValue(); int lowest = val + sb.getVisibleAmount(); int maxVal = sb.getMaximum(); boolean atBottom = maxVal == lowest; return atBottom; } private void scrollToBottom() { chatArea.setCaretPosition(chatArea.getDocument().getLength()); } Now, this works, but it's janky and not ideal for two reasons. By setting the caret position, whatever selection the user may have in the chat area is erased. I can imagine this would be very irritating if he's attempting to copy/paste. Since the advancement of the scroll pane occurs after the text is inserted, there is a split second where the scrollbar is in the wrong position, and then it visually jumps towards the end. This is not ideal. Before you ask, yes I've read this blog post on Text Area Scrolling, but the default scroll to bottom behavior is not what I want. Other related (but to my mind, not completely helpful in this regard) questions: Setting scroll bar on a jscrollpane Making a JScrollPane automatically scroll all the way down. Any help in this regard would be very much appreciated.

    Read the article

  • Javascript how many characters replaced in a regex?

    - by macca1
    I am sanitizing an input field and manually getting and setting the caret position in the process. With some abstraction, here's the basic idea: <input type="text" onkeyup"check(this)"> And javascript... function check(element) { var charPosition = getCaretPosition(element); $(element).val( sanitize( $(element).val() ) ); setCaretPosition(element, charPosition); } function sanitize(s) { return s.replace(/[^a-zA-Z0-9\s]/g, ''); } This is working fine except when a character does actually get sanitized, my caret position is off by one. Basically I'd like a way to see if the sanitize function has actually replaced a character (and at what index) so then I can adjust the charPosition if necessary. Any ideas?

    Read the article

  • Can I fire a Text Changed Event for an asp.net Text Box before it loses focus?

    - by Xaisoft
    I have an asp.net TextBox in which I want to check if the text entered into the TextBox is > 0. It works once I tab out or click out of the TextBox, but if I keep focus on the TextBox, it won't fire the Text Changed Event, so I have the following scenario, I want to enable something if and only if the TextBox.Text.Length = 0. Now, if I put my caret in the TextBox and delete all the characters and then leave the caret in the TextBox so it still has focus and take my mouse and click a button, it will not do what it was supposed to do because it never fired the Text Changed Event. How would something like this be handled?

    Read the article

  • What option in Visual Studio let catching exception where it occurred?

    - by macias
    VS 2010. The same WPF project, debug mode, two computers: A -- when exception occurrs the caret is placed at the point of exception B -- when the exception occurrs, correct exception is placed but always caret is placed at "win.ShowDialog()" in App.xaml.cs -- this is main entry for showing & running my application, in such case it is very tiresome to track down where the exception occurred What kind of settings control such behaviour? Of course I would like to switch B, so when exception hits I would be place at the point of exception, not at the main entry.

    Read the article

  • WPF texbox focus when render to offscreen buffer

    - by dr.mo
    i am rendering a textbox to an offscreen buffer using RenderTargetBitmap and i want to enter text into this textbox, however, i can't set the textbox focus (using Focus() has no effect - presumably because the canvas is not attached to a real window?) this has two consequenes: 1 the keyboard input doesn't get captured 2. even if i set the text manually using TextBox text and CaretIndex = index i dont get a caret because of the lack of focus. is there a way to make this focus somehow? and if not, i'd like to at least have the caret visible even if there is no focus, but can't see a way of doing this.

    Read the article

  • How do you replace many characters in a regex?

    - by macca1
    I am sanitizing an input field and manually getting and setting the caret position in the process. With some abstraction, here's the basic idea: <input type="text" onkeyup"check(this)"> And javascript... function check(element) { var charPosition = getCaretPosition(element); $(element).val( sanitize( $(element).val() ) ); setCaretPosition(element, charPosition); } function sanitize(s) { return s.replace(/[^a-zA-Z0-9\s]/g, ''); } This is working fine except when a character does actually get sanitized, my caret position is off by one. Basically I'd like a way to see if the sanitize function has actually replaced a character (and at what index) so then I can adjust the charPosition if necessary. Any ideas?

    Read the article

  • How to see functions implemented in R packages

    - by rinzy kutex
    How do I see the actual code for the functions implemented in R packaged. For instance I have loaded the caret package and I would like to see the code used for the function "createMultiFolds". I have gone to where the packages are stored but can't seem to find what I am looking for. For instance folders like Meta in the root folder of the caret package have files with the .rds extension which I can read into R with the gzfile command but I can't still seem to find what I am looking for i.e. the exact for the functions e.g. creatMultifolds. I would like to adapt some of these functions specifically to my research needs by make small changes to the codes to output the results in the way that I want without having to "re-invent the wheel" I will be glad if someone can help me. Thanks.

    Read the article

  • How to insert inline content from one FlowDocument into another?

    - by Robert Rossney
    I'm building an application that needs to allow a user to insert text from one RichTextBox at the current caret position in another one. I spent a lot of time screwing around with the FlowDocument's object model before running across this technique - source and target are both FlowDocuments: using (MemoryStream ms = new MemoryStream()) { TextRange tr = new TextRange(source.ContentStart, source.ContentEnd); tr.Save(ms, DataFormats.Xaml); ms.Seek(0, SeekOrigin.Begin); tr = new TextRange(target.CaretPosition, target.CaretPosition); tr.Load(ms, DataFormats.Xaml); } This works remarkably well. The only problem I'm having with it now is that it always inserts the source as a new paragraph. It breaks the current run (or whatever) at the caret, inserts the source, and ends the paragraph. That's appropriate if the source actually is a paragraph (or more than one paragraph), but not if it's just (say) a line of text. I think it's likely that the answer to this is going to end up being checking the target to see if it consists entirely of a single block, and if it does, setting the TextRange to point at the beginning and end of the block's content before saving it to the stream. The entire world of the FlowDocument is a roiling sea of dark mysteries to me. I can become an expert at it if I have to (per Dostoevsky: "Man is the animal who can get used to anything."), but if someone has already figured this out and can tell me how to do this it would make my life far easier.

    Read the article

  • gunit syntax for tree walker with a flat list of nodes

    - by Kaleb Pederson
    Here's a simple gunit test for a portion of my tree grammar which generates a flat list of nodes: objectOption walks objectOption: <<one:"value">> -> (one "value") Although you define a tree in ANTLR's rewrite syntax using a caret (i.e. ^(ROOT child...)), gunit matches trees without the caret, so the above represents a tree and it's not surprising that it fails: it's a flat list of nodes and not a tree. This results in a test failure: 1 failures found: test2 (objectOption walks objectOption, line17) - expected: (one \"value\") actual: one \"value\" Another option which seems intuitive is to leave off the parenthesis, like this: objectOption walks objectOption: <<one:"value">> -> one "value" But gunit doesn't like this syntax. It seems to result in a parse failure in the gunit grammar: line 17:20 no viable alternative at input 'one' line 17:24 missing ':' at 'value' line 0:-1 no viable alternative at input '<EOF>' java.lang.NullPointerException at org.antlr.gunit.OutputTest.getExpected(OutputTest.java:65) at org.antlr.gunit.gUnitExecutor.executeTests(gUnitExecutor.java:245) ... What is the correct way to match a flat tree?

    Read the article

< Previous Page | 1 2 3 4 5 6  | Next Page >