Re: [Win32Lib] type in mle after select item from tree view?
- Posted by Dan Moyer <DANIELMOYER at prodigy.net> Nov 25, 2002
- 432 views
Derek, Thanks! What a weird approach; after trying to beat it into my brain, "use onChange" for lists & TVs, here you go & use "onClick"! ;) But it seems to work, what makes you say it's not foolproof? Double-clicking is the only thing I've found that sets focus back to the TV. Dan ----- Original Message ----- From: "Derek Parnell" <ddparnell at bigpond.com> To: "EUforum" <EUforum at topica.com> Subject: Re: [Win32Lib] type in mle after select item from tree view? > > Hi Dan, > I've got something working. > > The problem seems to be that Windows grabs focus again when you release the > mouse button. The method below is not foolproof but it works kinda... > > Just replace the event handler code and setHandler() thus... > > > object w w = -2 > procedure TreeView2_onChange (integer self, integer event, sequence > params)--params is () > object x > > if event = w32HClick then > w = -1 -- Begin processing mouse movements. > else > if params[1] = WM_MOUSEMOVE and equal(w,-1) then > x = getTVIndex(TreeView2) > if equal(w,x) = False then > setText(MleText3, "Item " & sprint(getTVIndex(TreeView2)) & > CrLf & "I would like that the user could start " & > "entering text at the end of this text immediately > after selecting a TV item," & > " without having to click the mouse over here first. " > & > " Focus was just set here, but doesn't seem to work.") > setFocus(MleText3) > setIndex(MleText3, {1,0}) -- hilite all the text. > w = x > end if > end if > end if > end procedure > setHandler( TreeView2, {w32HEvent, w32HClick}, > routine_id("TreeView2_onChange")) > > > ---------------- > cheers, > Derek Parnell > ----- Original Message ----- > From: "Dan Moyer" <DANIELMOYER at prodigy.net> > To: "EUforum" <EUforum at topica.com> > Sent: Monday, November 25, 2002 6:14 PM > Subject: [Win32Lib] type in mle after select item from tree view? > > > > I have a TreeView and a multi-line edit box in a program; I'd like that > when > > the program user selects an item from the TV, they could immediately begin > > to enter text into the mle. But when I setFocus at the end of a TV change > > event, it doesn't do that. I have to *click* on the mle before I can > enter > > text. Am I doing something wrong? problem demo follows below. > > > > Dan Moyer > > > > --<code begins> > > > > -- code generated by Win32Lib IDE v0.14.2 > > > > include Win32lib.ew > > without warning > > > > -------------------------------------------------------------------------- > -- > > ---- > > -- Window Window1 > > constant Window1 = createEx( Window, "Window1", 0, Default, Default, 400, > > 300, 0, 0 ) > > constant TreeView2 = createEx( TreeView, "TreeView2", Window1, 12, 12, > 176, > > 248, or_all({TVS_HASLINES,TVS_LINESATROOT,TVS_SHOWSELALWAYS}), 0 ) > > constant MleText3 = createEx( MleText, "", Window1, 208, 16, 176, 244, 0, > > 0 ) > > --------------------------------------------------------- > > -------------------------------------------------------------------------- > -- > > ---- > > constant CrLf = { '\r', '\n' } > > integer dummy > > -------------------------------------------------------------------------- > -- > > ---- > > procedure Window1_onActivate (integer self, integer event, sequence > > params)--params is () > > for n = 1 to 10 do > > dummy = addTVItem(TreeView2, 0,0, sprint(n), 0) > > end for > > setText(MleText3, "Click on a Tree View item") > > end procedure > > setHandler( Window1, w32HActivate, routine_id("Window1_onActivate")) > > -------------------------------------------------------------------------- > -- > > ---- > > procedure TreeView2_onChange (integer self, integer event, sequence > > params)--params is () > > setText(MleText3, "Item " & sprint(getTVIndex(TreeView2)) & > > CrLf & "I would like that the user could start " & > > "entering text at the end of this text immediately after > > selecting a TV item," & > > " without having to click the mouse over here first. " & > > " Focus was just set here, but doesn't seem to work.") > > setFocus(MleText3) > > end procedure > > setHandler( TreeView2, w32HChange, routine_id("TreeView2_onChange")) > > > > > > WinMain( Window1,Normal ) > > > > --<code ends> > > > > > > >