1. RE: [win32] cursor
- Posted by Brian Broker <bkb at cnw.com> Nov 06, 2002
- 397 views
You might consider using sendMessage and EM_REPLACESEL instead of your method outlined below. Example: out = allocate_string("something to insert") if sendMessage(myctrl,EM_REPLACESEL,True,out) then end if free(out) Only problem might be making sure nothing is selected at the time because it will be replaced. If nothing is selected then it just inserts text at point of cursor... -- Brian mistertrik wrote: > bah.... ok thanks. > > I think that there should be at least a wrapper func called > getCursorPosition or something. > > Also, to insert text where the cursor is, it looks like I'm going to > have to > do something like this: > sequence text > atom pos > text = getText(myctrl) > pos = getIndex(myctrl) > setText(myctrl, text[1..pos] & "hello there" & > text[pos+1..length(text)]) > > In my mind, when setSelectedText was called, if there wasn't anything > selected it would insert text at the cursor position. > That seems to be more logical, rather than do nothing. > > ===================================================== > .______<-------------------\__ > / _____<--------------------__|=== > ||_ <-------------------/ > \__| Mr Trick > > > >From: Derek Parnell <ddparnell at bigpond.com> > >Reply-To: EUforum at topica.com > >To: EUforum <EUforum at topica.com> > >Subject: Re: [win32] cursor > >Date: Thu, 07 Nov 2002 11:37:49 +1100 > > > > > >Its not documented as such but the getIndex() call will return the > >cursor > >location from an edit or > >richedit box. Currently the docs only mention ListView and Treeview, but > >it > >also works for Listbox > >and Combos. > > > >7/11/2002 11:27:13 AM, mistertrik at hotmail.com wrote: > > > > > > > >How do you find the cursor position in a MLEedit? > > > > > >I have an edit window, and I want to be able to insert a string into > >where > > >the cursor position is. > > > > > >===================================================== > > >.______<-------------------\__ > > >/ _____<--------------------__|=== > > >||_ <-------------------/ > > >\__| Mr Trick > > > > > > > >--------- > >Cheers, > >Derek Parnell > >ICQ# 7647806 > > > >
2. Re: RE: [win32] cursor
- Posted by Derek Parnell <ddparnell at bigpond.com> Nov 06, 2002
- 415 views
Actually you can do this in the current Win32lib... insertText(myctrl, "hello there") instead of the getIndex() and setText() method. Also, setIndex() does set the cursor position in edit boxes. 7/11/2002 12:35:50 PM, Brian Broker <bkb at cnw.com> wrote: > >You might consider using sendMessage and EM_REPLACESEL instead of your >method outlined below. > >Example: > > out = allocate_string("something to insert") > if sendMessage(myctrl,EM_REPLACESEL,True,out) then end if > free(out) > >Only problem might be making sure nothing is selected at the time >because it will be replaced. If nothing is selected then it just >inserts text at point of cursor... > >-- Brian > >mistertrik wrote: >> bah.... ok thanks. >> >> I think that there should be at least a wrapper func called >> getCursorPosition or something. >> >> Also, to insert text where the cursor is, it looks like I'm going to >> have to >> do something like this: >> sequence text >> atom pos >> text = getText(myctrl) >> pos = getIndex(myctrl) >> setText(myctrl, text[1..pos] & "hello there" & >> text[pos+1..length(text)]) >> >> In my mind, when setSelectedText was called, if there wasn't anything >> selected it would insert text at the cursor position. >> That seems to be more logical, rather than do nothing. >> >> ===================================================== >> .______<-------------------\__ >> / _____<--------------------__|=== >> ||_ <-------------------/ >> \__| Mr Trick >> >> >> >From: Derek Parnell <ddparnell at bigpond.com> >> >Reply-To: EUforum at topica.com >> >To: EUforum <EUforum at topica.com> >> >Subject: Re: [win32] cursor >> >Date: Thu, 07 Nov 2002 11:37:49 +1100 >> > >> > >> >Its not documented as such but the getIndex() call will return the >> >cursor >> >location from an edit or >> >richedit box. Currently the docs only mention ListView and Treeview, but >> >it >> >also works for Listbox >> >and Combos. >> > >> >7/11/2002 11:27:13 AM, mistertrik at hotmail.com wrote: >> > >> > > >> > >How do you find the cursor position in a MLEedit? >> > > >> > >I have an edit window, and I want to be able to insert a string into >> >where >> > >the cursor position is. >> > > >> > >===================================================== >> > >.______<-------------------\__ >> > >/ _____<--------------------__|=== >> > >||_ <-------------------/ >> > >\__| Mr Trick >> > > >> > > >> >--------- >> >Cheers, >> >Derek Parnell >> >ICQ# 7647806 >> > >> > > > > --------- Cheers, Derek Parnell ICQ# 7647806
3. Re: RE: [win32] cursor
- Posted by Derek Parnell <ddparnell at bigpond.com> Nov 06, 2002
- 383 views
Just to clarify and guard against replacing selected text... setIndex(myctrl, getIndex(myctrl)) insertText(myctrl, "hello there") By the way Brian and others, the sendMessage() call can handle strings as parameters. Thus you could do this... VOID = sendMessage(myctrl, EM_REPLACESEL, True, "hello there") without the allocate_string() and free() calls. Win32lib is trying to make things easy to do, so a lot of little necessary housekeeping tasks are done for you. 7/11/2002 1:26:41 PM, Derek Parnell <ddparnell at bigpond.com> wrote: > >Actually you can do this in the current Win32lib... > > insertText(myctrl, "hello there") > >instead of the getIndex() and setText() method. > >Also, setIndex() does set the cursor position in edit boxes. > > >7/11/2002 12:35:50 PM, Brian Broker <bkb at cnw.com> wrote: > >> >>You might consider using sendMessage and EM_REPLACESEL instead of your >>method outlined below. >> >>Example: >> >> out = allocate_string("something to insert") >> if sendMessage(myctrl,EM_REPLACESEL,True,out) then end if >> free(out) >> >>Only problem might be making sure nothing is selected at the time >>because it will be replaced. If nothing is selected then it just >>inserts text at point of cursor... >> >>-- Brian >> >>mistertrik wrote: >>> bah.... ok thanks. >>> >>> I think that there should be at least a wrapper func called >>> getCursorPosition or something. >>> >>> Also, to insert text where the cursor is, it looks like I'm going to >>> have to >>> do something like this: >>> sequence text >>> atom pos >>> text = getText(myctrl) >>> pos = getIndex(myctrl) >>> setText(myctrl, text[1..pos] & "hello there" & >>> text[pos+1..length(text)]) >>> >>> In my mind, when setSelectedText was called, if there wasn't anything >>> selected it would insert text at the cursor position. >>> That seems to be more logical, rather than do nothing. >>> >>> ===================================================== >>> .______<-------------------\__ >>> / _____<--------------------__|=== >>> ||_ <-------------------/ >>> \__| Mr Trick >>> >>> >>> >From: Derek Parnell <ddparnell at bigpond.com> >>> >Reply-To: EUforum at topica.com >>> >To: EUforum <EUforum at topica.com> >>> >Subject: Re: [win32] cursor >>> >Date: Thu, 07 Nov 2002 11:37:49 +1100 >>> > >>> > >>> >Its not documented as such but the getIndex() call will return the >>> >cursor >>> >location from an edit or >>> >richedit box. Currently the docs only mention ListView and Treeview, but >>> >it >>> >also works for Listbox >>> >and Combos. >>> > >>> >7/11/2002 11:27:13 AM, mistertrik at hotmail.com wrote: >>> > >>> > > >>> > >How do you find the cursor position in a MLEedit? >>> > > >>> > >I have an edit window, and I want to be able to insert a string into >>> >where >>> > >the cursor position is. >>> > > >>> > >===================================================== >>> > >.______<-------------------\__ >>> > >/ _____<--------------------__|=== >>> > >||_ <-------------------/ >>> > >\__| Mr Trick >>> > > >>> > > >>> >--------- >>> >Cheers, >>> >Derek Parnell >>> >ICQ# 7647806 >>> > >>> > >--------- >Cheers, >Derek Parnell >ICQ# 7647806 > > > > <snip> Cheers, Derek Parnell ICQ# 7647806
4. Re: RE: [win32] cursor
- Posted by mistertrik at hotmail.com Nov 06, 2002
- 400 views
I tried that, and in the IDE it recognised it, but it said it couldn't find it when I ran the program.. I must have an older version of win32lib. ===================================================== .______<-------------------\__ / _____<--------------------__|=== ||_ <-------------------/ \__| Mr Trick >From: Derek Parnell <ddparnell at bigpond.com> >Subject: Re: RE: [win32] cursor > > >Actually you can do this in the current Win32lib... > > insertText(myctrl, "hello there") > >instead of the getIndex() and setText() method. > >Also, setIndex() does set the cursor position in edit boxes. > > >7/11/2002 12:35:50 PM, Brian Broker <bkb at cnw.com> wrote: > > > > >You might consider using sendMessage and EM_REPLACESEL instead of your > >method outlined below. > > > >Example: > > > > out = allocate_string("something to insert") > > if sendMessage(myctrl,EM_REPLACESEL,True,out) then end if > > free(out) > > > >Only problem might be making sure nothing is selected at the time > >because it will be replaced. If nothing is selected then it just > >inserts text at point of cursor... > > > >-- Brian > > > >mistertrik wrote: > >> bah.... ok thanks. > >> > >> I think that there should be at least a wrapper func called > >> getCursorPosition or something. > >> > >> Also, to insert text where the cursor is, it looks like I'm going to > >> have to > >> do something like this: > >> sequence text > >> atom pos > >> text = getText(myctrl) > >> pos = getIndex(myctrl) > >> setText(myctrl, text[1..pos] & "hello there" & > >> text[pos+1..length(text)]) > >> > >> In my mind, when setSelectedText was called, if there wasn't anything > >> selected it would insert text at the cursor position. > >> That seems to be more logical, rather than do nothing. > >> > >> ===================================================== > >> .______<-------------------\__ > >> / _____<--------------------__|=== > >> ||_ <-------------------/ > >> \__| Mr Trick > >> > >> > >> >From: Derek Parnell <ddparnell at bigpond.com> > >> >Reply-To: EUforum at topica.com > >> >To: EUforum <EUforum at topica.com> > >> >Subject: Re: [win32] cursor > >> >Date: Thu, 07 Nov 2002 11:37:49 +1100 > >> > > >> > > >> >Its not documented as such but the getIndex() call will return the > >> >cursor > >> >location from an edit or > >> >richedit box. Currently the docs only mention ListView and Treeview, >but > >> >it > >> >also works for Listbox > >> >and Combos. > >> > > >> >7/11/2002 11:27:13 AM, mistertrik at hotmail.com wrote: > >> > > >> > > > >> > >How do you find the cursor position in a MLEedit? > >> > > > >> > >I have an edit window, and I want to be able to insert a string into > >> >where > >> > >the cursor position is. > >> > > > >> > >===================================================== > >> > >.______<-------------------\__ > >> > >/ _____<--------------------__|=== > >> > >||_ <-------------------/ > >> > >\__| Mr Trick > >> > > > >> > > > >> >--------- > >> >Cheers, > >> >Derek Parnell > >> >ICQ# 7647806 > >> > > >> > <snip> > >
5. Re: RE: [win32] cursor
- Posted by Derek Parnell <ddparnell at bigpond.com> Nov 06, 2002
- 407 views
global procedure insertText( integer id, sequence text ) -- replace selection; True means allow undo VOID = sendMessage( id, EM_REPLACESEL, True, text) end procedure 7/11/2002 2:13:05 PM, mistertrik at hotmail.com wrote: > >I tried that, and in the IDE it recognised it, but it said it couldn't find >it when I ran the program.. I must have an older version of win32lib. >===================================================== >.______<-------------------\__ >/ _____<--------------------__|=== >||_ <-------------------/ >\__| Mr Trick > > >>From: Derek Parnell <ddparnell at bigpond.com> >>Reply-To: EUforum at topica.com >>To: EUforum <EUforum at topica.com> >>Subject: Re: RE: [win32] cursor >>Date: Thu, 07 Nov 2002 13:26:41 +1100 >> >> >>Actually you can do this in the current Win32lib... >> >> insertText(myctrl, "hello there") >> >>instead of the getIndex() and setText() method. >> >>Also, setIndex() does set the cursor position in edit boxes. >> >> >>7/11/2002 12:35:50 PM, Brian Broker <bkb at cnw.com> wrote: >> >> > >> >You might consider using sendMessage and EM_REPLACESEL instead of your >> >method outlined below. >> > >> >Example: >> > >> > out = allocate_string("something to insert") >> > if sendMessage(myctrl,EM_REPLACESEL,True,out) then end if >> > free(out) >> > >> >Only problem might be making sure nothing is selected at the time >> >because it will be replaced. If nothing is selected then it just >> >inserts text at point of cursor... >> > >> >-- Brian >> > >> >mistertrik wrote: >> >> bah.... ok thanks. >> >> >> >> I think that there should be at least a wrapper func called >> >> getCursorPosition or something. >> >> >> >> Also, to insert text where the cursor is, it looks like I'm going to >> >> have to >> >> do something like this: >> >> sequence text >> >> atom pos >> >> text = getText(myctrl) >> >> pos = getIndex(myctrl) >> >> setText(myctrl, text[1..pos] & "hello there" & >> >> text[pos+1..length(text)]) >> >> >> >> In my mind, when setSelectedText was called, if there wasn't anything >> >> selected it would insert text at the cursor position. >> >> That seems to be more logical, rather than do nothing. >> >> >> >> ===================================================== >> >> .______<-------------------\__ >> >> / _____<--------------------__|=== >> >> ||_ <-------------------/ >> >> \__| Mr Trick >> >> >> >> >> >> >From: Derek Parnell <ddparnell at bigpond.com> >> >> >Reply-To: EUforum at topica.com >> >> >To: EUforum <EUforum at topica.com> >> >> >Subject: Re: [win32] cursor >> >> >Date: Thu, 07 Nov 2002 11:37:49 +1100 >> >> > >> >> > >> >> >Its not documented as such but the getIndex() call will return the >> >> >cursor >> >> >location from an edit or >> >> >richedit box. Currently the docs only mention ListView and Treeview, >>but >> >> >it >> >> >also works for Listbox >> >> >and Combos. >> >> > >> >> >7/11/2002 11:27:13 AM, mistertrik at hotmail.com wrote: >> >> > >> >> > > >> >> > >How do you find the cursor position in a MLEedit? >> >> > > >> >> > >I have an edit window, and I want to be able to insert a string into >> >> >where >> >> > >the cursor position is. >> >> > > >> >> > >===================================================== >> >> > >.______<-------------------\__ <snip> > > > Cheers, Derek Parnell ICQ# 7647806