Re: Edit text fields in child windows
- Posted by Rad <radhx at rediffmail.com> Apr 28, 2007
- 496 views
CChris wrote: > > Limiting text length, ie the amount of characters, won't work, this is a > feature of EditText controls. > > I had posted the following test code: > }}} <eucode> > constant Window1 = createEx( Window, "Window1", 0, Default, Default, 200, 140, > 0, 0 ) > constant CWindow3 = createEx( Window, "", Window1, 56, 24, 200, 100, > w32or_all({WS_CHILD}), > 0 ) > openWindow(CWindow3, Normal) > constant EditText4 = createEx( RichEdit, "EditText4", CWindow3, 8, 28, 48, 20, > {w32or_all( { WS_CLIPPINGCHILD, > WS_VISIBLE, > ES_AUTOHSCROLL, > WS_TABSTOP, > ES_SAVESEL, > WS_BORDER } )} > , 0 ) > > WinMain( Window1,Normal ) > </eucode> {{{ > Try it and see if this displays decently enough for your purpose. At least, > it won't go to next line on pressing enter and won't display horizontal > scroll bars. You can't remove some styles after creation, so be sure to > create the control with the right styles. > > Why do you need the parent window to be a child window? The only benefit > this style gives you is auto clipping (wrt both parent and siblings), and I > just can't figure how windows with edit controls benefit from that. > Removing the style will enable you to use EditTexts as you initially > intended. > > CChris Thanks CChris & Dan, Mouse Clicks worked on RichText within a Cwindow. Multiple lines issue also got solved with the code provided by CChris. For that, in IDE, instead of {w32or_all{}}, I had to use {...}. The "Limit text to" property is also working on RichText. But now I have a new issue. To make focus pass to next control on pressing Enter or Tab key, I used following code (for all RichTexts)-
procedure RichEdit41_onKeyUp (integer self, integer event, sequence params)--params is ( int scanCode, int shift ) if find(params[1], {VK_RETURN, VK_TAB}) then putStream(self, StreamText, trim(getStream(self, StreamText))) -- to remove tab from the text if params[2] = 0 then tab_direction(self, 1) elsif (and_bits(params[2], ShiftMask) and params[1] = VK_TAB) then tab_direction(self, -1) end if end if end procedure setHandler( RichEdit41, w32HKeyUp, routine_id("RichEdit41_onKeyUp"))
This code works fine as long as there is no other control between 2 (or more) RichTexts in a Cwindow. Say if you have 3 fields in a Cwindow in following sequence - field1 - RichText field2 - Combo field3 - RichText When focus is on field1 and you press Enter/Tab key on field1, focus properly moves to field2. But when you again press Enter/Tab key on field2, instead of focus being moved to field3, it moves to field1. Looks like Enter/Tab key pressed on field2 is processed by Keyup procedure of field3. Similar thing happens when Shift+Tab key is pressed. Any suggestions? Regards, Rad.