Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.sys.acorn.programmer > #216
| Date | 2011-04-26 23:17 +0100 |
|---|---|
| From | Matthew Phillips <mnews@sinenomine.freeserve.co.uk> |
| Newsgroups | comp.sys.acorn.programmer |
| Subject | Re: How to put a caret in a window |
| Message-ID | <702330ca51.Matthew@sinenomine.freeserve.co.uk> (permalink) |
| References | <51c98770d3Paul@sprie.nl> <3f7697c951.Matthew@sinenomine.freeserve.co.uk> <51c9a7e1b5Paul@sprie.nl> |
In message <51c9a7e1b5Paul@sprie.nl> on 25 Apr 2011 Paul Sprangers wrote: > > Try Wimp_SetCaretPosition. You can work out the required position using > > Font_ScanString, but making it appear needs Wimp_SetCaretPosition. > > Thank you for your prompt advise. > However, it doesn't stop me muddling. > The StrongHelp files say (amongst other enigmas) that R5 should contain the > Index into string on entry. What on earth is an Index into string? > > Could you perhaps provide some sample code? Or add corrections to mine? > Here's what I have so far: > > DEF PROCredraw(wh%) > !block%=wh% > SYS "Wimp_GetWindowInfo",,block% > SYS "Wimp_RedrawWindow",,block% TO more% > ox%=block%!4-block%!20 > oy%=block%!16-block%!24 > WHILE more% > SYS "Wimp_SetFontColours",,0,7 > SYS "Font_SetFont",plain% > SYS "Font_Paint",,string$,16,ox%+10,oy%-30 > SYS "Font_ScanString",0,string$,&20100,0,0 TO ,,,cx%,cy% Not sure about setting bit 8 in the flags when your R0 value is 0. I'd put R0 equal to plain% but it may not matter. You have set bit 17 to return the nearest caret position in R3,4 but the "mouse click" x,y you are passing in is zero. If you use these values you'll be getting the caret appearing at the *start* of the string. You'll need to pass a large integer as the initial value of R3 and R4 (i.e. to pretend your "mouse click" for placing the caret is way off the right-hand end). I've found that passing 7FFFFFFF sometimes causes problems so go for something not quite so big like &3FFFFFFF. You should also set R7 to the length of the string (if you choose a value "n" for R7 then the caret position "n" characters into the string will be returned). > SYS "Wimp_SetCaretPosition",wh%,-1,cx%,cy%,????? The values in cx% and cy% will be relative to plotting the string at 0,0 so you will need to adjust the caret placement according to where you are actually painting the string. Font_Paint takes the x and y relative to the screen origin, but Wimp_SetCaretPosition will be relative to the window work area origin. Nasty sums! The Wimp_SetCaretPosition should not really be in the redraw loop. You should be doing this when the caret is placed. The Wimp redraws the caret for you. R5 should be -1 -- the index into string value only applies if you are placing the caret in a writable icon, and you are placing it at a specific location on the window background. By "index into the string" it means how many characters from the start of the string in the writable icon should the caret be placed at. Actually it's not characters, strictly speaking, it's bytes in the case of multi-byte character sets like UTF-8. You want "-1" anyway, so don't worry. R4 is more tricky. I don't think you have to worry about the height of the caret when just placing it in a writable icon. On the window background you may need to be specific. It's just in OS units. Put something reasonably sensible in to get started, and tweak later if there's any chance the font size is going to vary. > SYS "Wimp_GetRectangle",,block% TO more% > ENDWHILE > ENDPROC > > No doubt, the way I use the Font_ScanString call, is mud as well. > This routine, however, does paint the desired string to the desired > position (after having REMmed out the SetCaretPosition line, of course), > but how do I get the equally desired caret after that string? Hope that helps, -- Matthew Phillips Durham
Back to comp.sys.acorn.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
How to put a caret in a window Paul Sprangers <Paul@sprie.nl> - 2011-04-25 17:34 +0200
Re: How to put a caret in a window Matthew Phillips <mnews@sinenomine.freeserve.co.uk> - 2011-04-25 19:29 +0100
Re: How to put a caret in a window Paul Sprangers <Paul@sprie.nl> - 2011-04-25 23:28 +0200
Re: How to put a caret in a window Matthew Phillips <mnews@sinenomine.freeserve.co.uk> - 2011-04-26 23:17 +0100
Re: How to put a caret in a window Matthew Phillips <mnews@sinenomine.freeserve.co.uk> - 2011-04-27 07:38 +0100
Re: How to put a caret in a window Paul Sprangers <Paul@sprie.nl> - 2011-04-27 13:31 +0200
Re: How to put a caret in a window Jeremy Nicoll - news posts <jn.nntp.scrap007@wingsandbeaks.org.uk> - 2011-04-27 13:14 +0100
Re: How to put a caret in a window Paul Sprangers <Paul@sprie.nl> - 2011-04-27 17:15 +0200
Re: How to put a caret in a window pdm <pd.miller2@tiscali.co.uk> - 2011-04-27 08:59 -0700
Re: How to put a caret in a window Paul Sprangers <Paul@sprie.nl> - 2011-04-27 21:50 +0200
Re: How to put a caret in a window pdm <pd.miller2@tiscali.co.uk> - 2011-04-27 23:19 -0700
Re: How to put a caret in a window Matthew Phillips <mnews@sinenomine.freeserve.co.uk> - 2011-04-27 19:58 +0100
Re: How to put a caret in a window Paul Sprangers <Paul@sprie.nl> - 2011-04-27 22:15 +0200
Re: How to put a caret in a window Martin Wuerthner <spamtrap@mw-software.com> - 2011-04-30 17:12 +0200
Re: How to put a caret in a window Rick Murray <heyrickmail-usenet@yahoo.co.uk> - 2011-04-30 19:12 +0200
Re: How to put a caret in a window Paul Sprangers <Paul@sprie.nl> - 2011-05-02 09:37 +0200
Re: How to put a caret in a window Alan Wrigley <spamhater@keepyourfilthyspamtoyourself.co.uk> - 2011-05-02 08:49 +0100
Re: How to put a caret in a window Paul Sprangers <Paul@sprie.nl> - 2011-05-02 09:59 +0200
Re: How to put a caret in a window Alan Adams <alan@adamshome.org.uk> - 2011-05-02 21:27 +0100
Re: How to put a caret in a window Steve Fryatt <news@stevefryatt.org.uk> - 2011-05-02 09:08 +0100
Re: How to put a caret in a window Paul Sprangers <Paul@sprie.nl> - 2011-04-30 12:54 +0200
Re: How to put a caret in a window Rick Murray <heyrickmail-usenet@yahoo.co.uk> - 2011-04-30 13:52 +0200
Re: How to put a caret in a window cferris@freeRemoveuk.com.invalid - 2011-04-30 13:34 +0100
Re: How to put a caret in a window Rick Murray <heyrickmail-usenet@yahoo.co.uk> - 2011-04-30 15:39 +0200
Re: How to put a caret in a window Matthew Phillips <mnews@sinenomine.freeserve.co.uk> - 2011-04-28 08:20 +0100
Re: How to put a caret in a window pdm <pd.miller2@tiscali.co.uk> - 2011-04-28 02:16 -0700
Re: How to put a caret in a window Paul Sprangers <Paul@sprie.nl> - 2011-04-29 17:49 +0200
Re: How to put a caret in a window Rick Murray <heyrickmail-usenet@yahoo.co.uk> - 2011-04-30 00:05 +0200
csiph-web