f



How to get selected text from a text edit control?

I created a text edit control using CreateEditTextControl.
I can get the current text by calling

char buf[256];
Size textSize = 0;
GetControlData(controlRef, kControlEditTextPart,
kControlEditTextTextTag, 255, buf, &textSize);

but how do I get only the text that is currently selected
(highlighted)?

thanks,

Shai

0
shai
3/17/2005 7:03:44 PM
comp.mac.codewarrior 2568 articles. 0 followers. ja7789 (3) is leader. Post Follow

3 Replies
1014 Views

Similar Articles

[PageSpeed] 53

In article <1111086224.345185.78280@g14g2000cwa.googlegroups.com>,
 shai@waves.com wrote:

> I created a text edit control using CreateEditTextControl.
> I can get the current text by calling
> 
> char buf[256];
> Size textSize = 0;
> GetControlData(controlRef, kControlEditTextPart,
> kControlEditTextTextTag, 255, buf, &textSize);
> 
> but how do I get only the text that is currently selected
> (highlighted)?
> 
> thanks,
> 
> Shai

char buf[256];
char * sel;
Size theSize = 0;
ControlEditTextSelectionRec selection;

GetControlData(controlRef, kControlEditTextPart, 
kControlEditTextTextTag, 255, buf, &theSize);
GetControlData(controlRef, kControlEditTextPart, 
kControlEditTextSelectionTag, sizeof(selection), &selection, &theSize);

sel = buf+selection.selStart;
sel[selection.selEnd] = '\0';

HTH,
-Will
0
Will
3/17/2005 7:27:29 PM
Thanks, Will, this is what I needed.


Will wrote:
> In article <1111086224.345185.78280@g14g2000cwa.googlegroups.com>,
>  shai@waves.com wrote:
>
> > I created a text edit control using CreateEditTextControl.
> > I can get the current text by calling
> >
> > char buf[256];
> > Size textSize = 0;
> > GetControlData(controlRef, kControlEditTextPart,
> > kControlEditTextTextTag, 255, buf, &textSize);
> >
> > but how do I get only the text that is currently selected
> > (highlighted)?
> >
> > thanks,
> >
> > Shai
>
> char buf[256];
> char * sel;
> Size theSize = 0;
> ControlEditTextSelectionRec selection;
>
> GetControlData(controlRef, kControlEditTextPart,
> kControlEditTextTextTag, 255, buf, &theSize);
> GetControlData(controlRef, kControlEditTextPart,
> kControlEditTextSelectionTag, sizeof(selection), &selection,
&theSize);
>
> sel = buf+selection.selStart;
> sel[selection.selEnd] = '\0';
> 
> HTH,
> -Will

0
shai
3/20/2005 8:10:51 AM
shai@waves.com wrote:
> I created a text edit control using CreateEditTextControl.
> I can get the current text by calling
>
> char buf[256];
> Size textSize = 0;
> GetControlData(controlRef, kControlEditTextPart,
> kControlEditTextTextTag, 255, buf, &textSize);

On Mac OS X this is considered old and undesirable. Is there a reason
you're using an Edit Text control instead of an Edit Unicode Text
control? And you should strongly consider getting the text as a
CFStringRef instead of a buffer of chars.

Larry

0
larry
3/21/2005 8:41:37 AM
Reply:

Similar Artilces:

Select and get text from Edit text filed
Hi, I need to make a simple text editor in matlab gui. I want is the user to be able to select part of the text he had typed and make the fontweight bold. I don't know how to get the selected text. Can you give me some clues? Thanks. ...

how to get the selected text in one edit control
can one tell me how to get the selected text in one edit control? thank you. Qingeng.Deng wrote: > can one tell me how to get the selected text in one edit control? You will have to do this using Java. Search some of Yair Altman's posts: he has posted pretty much the complete code. ...

GUI, edit control: selectable *and* un-editable text possible?
Dear Matlabbers, I'm working on a GUI with an edit control. It is used only to display text to the user, but it is necessary that the user can select parts of the text in order to copy it to clipboard. I tried to set it to 'Enable','inactive' to make it read-only, but nothing can be selected then. Is there a way to combine the properties of the text to be read-only and selectable? Heinrich Heinrich Acker wrote: > > > Dear Matlabbers, > > I'm working on a GUI with an edit control. It is used only to > display > text to the user, but it is necessar...

Using Control-a to select all text in a text widget
I'm having a difficult time binding Control-a so it selects all the text in a widget just like the default Control-/ binding does. I've tried: ..t bind <Control-a> [.t bind <Control-/>] But [.t bind <Control-/>] returns nothing. If I do: ..t bind <Control-/> {puts "Selecting all"} ..t bind <Control-a> [.t bind <Control-/>] When I hit Control-/ I get at the prompt "Selecting all" and all the text is selected. But when I hit Control-a all I get is the "Selecting all" at the prompt and no text is selected. I've als...

'GUI-Edit text ui control'-Way to detect mouse click in the edit text
Hi I am designing a graphical user interface. I have an edit text box. I would like that when a user double clicks inside the text box a new window open up with the options of inserting the text, else user can himself enter the text from the keyboard. The problem is that I am struggling to find a way to detect the mouse click inside the text box. I know about 'keypressfcn' but I suppose that does not check the mouse click. Please help me in this regard. Thank you in advace. Sumit "Olivier " <sumit.iitkgp@gmail.com> wrote in message <hq6ca7$r79$1@fred.mathwork...

Edit control used in TreeCtrl item edit gets wrong text on wxMSW
Hi all, I think I've found a cross platform discrepancy in the TreeCtrl implementation relating to the editing of tree item text. I'm using wxPython 2.5.3.1, but the problem seems to be wx related, not a problem with the bindings themselves. The problem arises from trying to make the editable tree item text to be different to the normal tree text (normal tree text 'MyName : type', but only 'MyName' is editable. I have some code that works on Linux, but not on wxMSW. I have two test cases; one using wxPython, where I know the problem exists, and one usin...

textarea: get text left and right from selected text
Hello everybody, I am looking for a method to get the text on the left and the right side if a user selects some text in a textarea. Regards Mario *** mariomueller escribi�/wrote (23 Aug 2006 12:31:43 -0700): > I am looking for a method to get the text on the left and the right > side if a user selects some text in a textarea. This article may help: http://www.quirksmode.org/js/selected.html -- -+ http://alvaro.es - �lvaro G. Vicario - Burgos, Spain ++ Mi sitio sobre programaci�n web: http://bits.demogracia.com +- Mi web de humor con rayos UVA: http://www.demogracia.com -- Hi ...

Rich text edit control & text-limit
The MS documentatation says text limit set by the EM_EXLIMITTEXT message does not limit the amount of text that one can stream into a rich edit control using the EM_STREAMIN message. I wrote a stream-in callback function, however the callback stops after more than 32767 character are read (I have more). The "SendMessage" function returns 32767. Am I missing something ? Thanks. ...

Re: How can labview update the string control (text-edit box) after we have pressed the carriage return key on the keyboard during text-editing within that box?
Hello Alberto, &nbsp; I have trouble to edit an exited text file and save it after the content changed. Can you please&nbsp;help me out? &nbsp; Thanks, Jason&nbsp; ...

Getting Unicode Text From Edit Control
Hi all. I am getting unexpected behavior/crashing when trying to get some lines of text from an Edit Control and then splitting them into lines (into a basic_string<TCHAR>*). This works fine for my non-Unicode version, but as soon as I #define UNICODE, _UNICODE, I get crashing on certain, apparently random lines of input. Here is the code I am currently using: int len = GetWindowTextLength(GetDlgItem(hwnd, ID_DIR)); TCHAR* dbuf = (TCHAR*)GlobalAlloc(GPTR, len + 1); GetDlgItemText(hwnd, ID_DIR, dbuf, MAX_PATH); int num; basic_string<TCHAR>* dirs; basic_string&l...

text + text
What is "text + text" supposed to do right now? It doesn't seem very useful to me. What about making "text + text" as an equivalent for "text || text"? Most strongly-typed programming languages do this. And MS SQL Server too, I think (CMIIW). -- dave ---------------------------(end of broadcast)--------------------------- TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org Am Freitag, 8. Oktober 2004 12:57 schrieb David Garamond: > What is "text + text" supposed to do right now? Nothing. > What a...

On SetFocus, the text in the textbox get selected. I want the prompt to be AFTER the text
Trough code I put focus on a textbox. My problem is that the existing letters in that text box get selected (black background) so when users type in new letters, the existing text is replaced. -Is there any way to awoid this? Like some code that do the some thing as a user that mouse clicks AFTER the text. My goal is that the users just should type on and Access should ADD what they type after whatever text is already in the textbox. Thank you for any info! Robert Robert_5032@yahoo.com wrote: > Trough code I put focus on a textbox. > My problem is that the existing letters in that t...

text-text
Wondering how what I input to my UTF-8 terminal gets passed along through my patched [1] trn ... Cyrillic: А Б В Г Д Е Ж З И Й К Л М Н О П а б в г д е ж з и й к л м н о п IPA: ᴀ ᴁ ᴂ ᴃ ᴄ ᴅ ᴆ ᴇ ᴈ ᴉ ᴊ ᴋ ᴌ ᴍ ᴎ ᴏ ɀ Ɂ ɂ Ƀ Ʉ Ʌ Ɇ ɇ Ɉ ɉ Ɋ ɋ Ɍ ɍ Ɏ ɏ [1] https://groups.google.com/d/msg/comp.sys.raspberry-pi/7Z37Hdrm0DM/6aqD-reXFzAJ ...

How to select all texts of the document of the format of the selected text?
Hi,i have selected a text of the document with the specified font face, color and size in MS Word 2000. Now , I want to select all the relevant texts from the entire document with the same format(face,color and size) as of the selected text. so Is there any method or shortcut to do this op.? Not really. You have to "walk" the document checking the styles as you go along. And You have to watch out for cases where the style changes in the middle of a word (!) and code accordingly to get the desired results. chetan26nov@gmail.com wrote: > Hi,i have selected a text of the documen...

Web resources about - How to get selected text from a text edit control? - comp.mac.codewarrior

Portal:Law/Nominate/Selected article - Wikipedia, the free encyclopedia
Add the article in to a subpage of this portal, such as Portal:Law/Selected article/# , replacing the "#" with the number above the current highest. ...

F8: Facebook’s FbStart Initiative Will Give Selected Developers A $30K Kick-Start
... successful applications is likely a whole lot easier with $30,000 in free tools and services to start off with, and that’s exactly what selected ...

LEGO Shop - The LEGO Technic team has selected the winner... - Facebook
The LEGO Technic team has selected the winner of the Co-Creation Challenge! LEGO will be producing a limited run of 20,000 of this stunning set.... ...

baby365- Grand Doctor Ma Selected Students for iPad on the iTunes App Store
Get baby365- Grand Doctor Ma Selected Students on the App Store. See screenshots and ratings, and read customer reviews.

Selected Cheney Vice Presidential Photographs
... for photos found within these albums are Paul Morse, Karen Ballard, Kimberlee Hewitt, Shealah Craighead, and Chris Greenberg. These selected ...

[iOS Advice] How To Clarify Your Email Replies By Quoting Selected Text - YouTube
Follow me on Twitter: http://www.twitter.com/macmixing Like my Facebook page: http://www.facebook.com/macmixing RATE, COMMENT, SUBSCRIBE! :-) ...

Local farmers to sell their fresh dates at selected supermarkets
Fresh dates will be on sale this summer under the label of Local Harvest at selected supermarkets and Spinney's.

Animal of the Day: Lucius Has Been Selected as the U.K.’s ‘Happiest Cat’
He’s got one blue eye, one green eye and a heart of gold. British mobile phone company O2 recently held some “cat auditions” to find “the UK’s ...

Michael Sam becomes first openly gay player selected in an NFL Draft
Defensive end Michael Sam of the University of Missouri became the first openly gay player to be selected in a National Football League Draft ...

Artist facing child pornography charges selected for MCA exhibition
An artist facing child pornography charges has been selected to show work in a prestigious exhibition at the Museum of Contemporary Art Australia. ...

Resources last updated: 1/27/2016 7:37:14 PM