1. CWindow and Mouse Clicks on EditText : work-around

Hi,

>> My Old Query >>
The EditText controls do not get focus with mouse clicks when their parent is
ChildWindow (CWindow) control. One can neither click and place the cursor on
them, nor can select a part or full text present in it. Other controls like
PushButtons, Combo etc respond correctly to mouse click. Only the EditText
control seems to have this problem.
>>

Doing further R&D on the issue, I got around the problem using following mods in
win32lib and my application:

win32lib: In function fDoMouse():
================================
lRC = {pReturn}
    if (and_bits(classAttr[ctrl_Type[id]], w32Clickable) != 0)
          or (ctrl_Family[id] = BUTTON)

	  -- 2007-07-22 Rad for receiving mouse click on EditText
	  or (ctrl_Family[id] = EDIT)
	  -- 2007-07-22 Rad for receiving mouse click on EditText

          or find(iMsg, {WM_RBUTTONDOWN, WM_MOUSEWHEEL})
          or (classType[ctrl_Type[id]] = STATIC and
and_bits(SS_NOTIFY, w32Func( xGetWindowLong, { ctrl_Handle[id],
               GWL_STYLE })) != 0)
          then
          doActions = w32True
    else
        doActions = w32False
    end if
    lParent = findParentWindow(id)



In my application's main window (MainMenu):
==========================================
procedure EditText_onClick(integer self, integer event, sequence params)
	setIndex(self, {1, 0})
	setFocus(self)
end procedure

procedure setEditClick(integer self)
sequence children, className
	className = getClassName(self)
	if equal(className, "Edit") then
		EditTextFlds = append(EditTextFlds, self)		
	end if
	children = findChildren(self)
	for i = 1 to length(children) do
		setEditClick(children[i][1])
	end for
end procedure

--#Set all EditText controls for receiving Mouse Click
EditTextFlds = {}
setEditClick(MainMenu)
setHandler(EditTextFlds, w32HClick, routine_id("EditText_onClick"))


With above mods, now I can click on EditText controls present in a Child Window
to access them.

Can this portion from my application be moved to win32lib in any way?
Looks like somehow default onClick setFocus event is not getting activated for
EditText controls.

Any suggestions?

Regards,
Rad.

new topic     » topic index » view message » categorize

2. Re: CWindow and Mouse Clicks on EditText : work-around

Rad wrote:
> 
> Hi,
> 
> >> My Old Query >>
> The EditText controls do not get focus with mouse clicks when their parent is
> ChildWindow (CWindow) control. One can neither click and place the cursor on
> them, nor can select a part or full text present in it. Other controls like
> PushButtons, Combo etc respond correctly to mouse click. Only the EditText
> control
> seems to have this problem.
> >>
> 
> Doing further R&D on the issue, I got around the problem using following mods
> in win32lib and my application:
> 
> win32lib: In function fDoMouse():
> ================================
> }}}
<eucode>
>     lRC = {pReturn}
>     if (and_bits(classAttr[ctrl_Type[id]], w32Clickable) != 0)
>           or (ctrl_Family[id] = BUTTON)
> 
> 	  -- 2007-07-22 Rad for receiving mouse click on EditText
> 	  or (ctrl_Family[id] = EDIT)
> 	  -- 2007-07-22 Rad for receiving mouse click on EditText
> 
>           or find(iMsg, {WM_RBUTTONDOWN, WM_MOUSEWHEEL})
>           or (classType[ctrl_Type[id]] = STATIC and
>                and_bits(SS_NOTIFY, w32Func( xGetWindowLong, { ctrl_Handle[id],
>                GWL_STYLE }))
> != 0)
>           then
>           doActions = w32True
>     else
>         doActions = w32False
>     end if
>     lParent = findParentWindow(id)
> </eucode>
{{{

> 
> 
> In my application's main window (MainMenu):
> ==========================================
> }}}
<eucode>
> procedure EditText_onClick(integer self, integer event, sequence params)
> 	setIndex(self, {1, 0})
> 	setFocus(self)
> end procedure
> 
> procedure setEditClick(integer self)
> sequence children, className
> 	className = getClassName(self)
> 	if equal(className, "Edit") then
> 		EditTextFlds = append(EditTextFlds, self)		
> 	end if
> 	children = findChildren(self)
> 	for i = 1 to length(children) do
> 		setEditClick(children[i][1])
> 	end for
> end procedure
> 
> --#Set all EditText controls for receiving Mouse Click
> EditTextFlds = {}
> setEditClick(MainMenu)
> setHandler(EditTextFlds, w32HClick, routine_id("EditText_onClick"))
> </eucode>
{{{

> 
> With above mods, now I can click on EditText controls present in a Child
> Window
> to access them.
> 
> Can this portion from my application be moved to win32lib in any way?
> Looks like somehow default onClick setFocus event is not getting activated for
> EditText controls.
> 
> Any suggestions?
> 
> Regards,
> Rad.


With your mod, do everything still work correctly when the  edit text is the
child of a top level window?

I am not against the change, but what you are trying to circumvent is not a but
in the library, but a standard behaviour of Windows, so some more care is needed.
If no one complains about changing that, then it owould certainly be useful.

CChris

new topic     » goto parent     » topic index » view message » categorize

3. Re: CWindow and Mouse Clicks on EditText : work-around

CChris wrote:
> 
> With your mod, do everything still work correctly when the  edit text is the
> child of a top level window?
> 
> I am not against the change, but what you are trying to circumvent is not a
> but in the library, but a standard behaviour of Windows, so some more care is
> needed. If no one complains about changing that, then it owould certainly be
> useful.
> 
> CChris

Yes, I can click on EditText in all Top/Parent/Child level windows to get
focus/access.

Actually, EditText focus was already working ok for Top level windows with
win32lib logic. Issue is only for child windows.
What I meant was is there any other way to set focus on EditText in child window
(like Top level), rather than collecting all the EditText's in application and
setting a handler for them?

Regards,
Rad.

new topic     » goto parent     » topic index » view message » categorize

4. Re: CWindow and Mouse Clicks on EditText : work-around

Rad wrote:
> 
> CChris wrote:
> > 
> > With your mod, do everything still work correctly when the  edit text is the
> > child of a top level window?
> > 
> > I am not against the change, but what you are trying to circumvent is not a
> > but in the library, but a standard behaviour of Windows, so some more care
> > is
> > needed. If no one complains about changing that, then it owould certainly be
> > useful.
> > 
> > CChris
> 
> Yes, I can click on EditText in all Top/Parent/Child level windows to get
> focus/access.
> 
> Actually, EditText focus was already working ok for Top level windows with
> win32lib
> logic. Issue is only for child windows.
> What I meant was is there any other way to set focus on EditText in child
> window
> (like Top level), rather than collecting all the EditText's in application and
> setting a handler for them?
> 
> Regards,
> Rad.

As I stated earlier, the EditText control relies on its parent window to ask it
to repaint on a mouse event. Top level windows will do that, child windows won't.
This is perhaps why Microsoft introduced the dreaded dialog boxes, where the box
collects all notifications from child controls and dispatches messages as needed.
This was probably the way Win1.0 implemented it, and they didn't wish to break
backward compatibility - see how clumsy that can get.

The behaviour is ingrained in the DefWindowProc wich Windows assigns to windows
with the WS_CHULD flag. What could probably be done is that fDoMouse() can send
the right message to the edit field if its parent window has the WS_CHILD style.
Needs some testing, and some care has to be taken so as not to degrade
performance of general mouse operations. If that works, then you won't need
setting handlers manually. I think that would be a property of the control
itself, so as not to call findParentWindow() needlessly.

Do you really need the clipping? If you don't, just set up your window without
the WS_CHILD style. It will behave properly, hidden when parent is hidden etc.
The only thing you'd lose besides clipping is the clipping, plus some extra
freedom of defining features of the window (has title bar, has buttons,...).
Check out the details on MSDN under "owned windows".

CChruis

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu