Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.clipper.visual-objects > #13097 > unrolled thread

Is there a simple property/method to ignore label of a checkbox?

Started byJafar <jafar@marti-orbak.nl>
First post2020-10-07 02:12 -0700
Last post2020-10-15 06:10 -0700
Articles 6 — 3 participants

Back to article view | Back to comp.lang.clipper.visual-objects


Contents

  Is there a simple property/method to ignore label of a checkbox? Jafar <jafar@marti-orbak.nl> - 2020-10-07 02:12 -0700
    Re: Is there a simple property/method to ignore label of a checkbox? "Wolfgang Riedmann" <wriedmann@gmail.com> - 2020-10-07 13:02 +0200
      Re: Is there a simple property/method to ignore label of a checkbox? Jafar <jafar@marti-orbak.nl> - 2020-10-15 02:19 -0700
        Re: Is there a simple property/method to ignore label of a checkbox? Robert Pope <cooeee@gmail.com> - 2020-10-15 03:23 -0700
          Re: Is there a simple property/method to ignore label of a checkbox? Jafar <jafar@marti-orbak.nl> - 2020-10-15 04:42 -0700
            Re: Is there a simple property/method to ignore label of a checkbox? Jafar <jafar@marti-orbak.nl> - 2020-10-15 06:10 -0700

#13097 — Is there a simple property/method to ignore label of a checkbox?

FromJafar <jafar@marti-orbak.nl>
Date2020-10-07 02:12 -0700
SubjectIs there a simple property/method to ignore label of a checkbox?
Message-ID<e490e2d4-52d3-4824-b358-101d378d8868n@googlegroups.com>
I am maintaining a VO app where the default behavior of a checkbox is limited to the checkbox rectangle itself.

The way this is done however is by adding an additional label that is not part of the checkbox itself.

Is there a simple way to avoid having to do this through a simple property/method without having to create additional labels all the time?

[toc] | [next] | [standalone]


#13098

From"Wolfgang Riedmann" <wriedmann@gmail.com>
Date2020-10-07 13:02 +0200
Message-ID<hu5lhhFo322U1@mid.individual.net>
In reply to#13097
Hi Jafar,

of course is that possible.
Create a subclass, and in the Init() method of this class you can
create your label.

The following code creates a pushbutton after a SingleLineEdit control:

method Init( oOwner, nID, oPoint, oDimension, kStyle ) class LookupSLE
    Super:Init( oOwner, nID, oPoint, oDimension, kStyle )
    _oPB := LookupPB{ self, self:ControlId + 300 }     
    _oPB:HyperLabel := HyperLabel{ self:Name + "_LOOKUP", "...", ;
			"", "" }
    return self

HTH

Wolfgang


> I am maintaining a VO app where the default behavior of a checkbox is
> limited to the checkbox rectangle itself.
> 
> The way this is done however is by adding an additional label that is
> not part of the checkbox itself.
> 
> Is there a simple way to avoid having to do this through a simple
> property/method without having to create additional labels all the
> time?



-- 

[toc] | [prev] | [next] | [standalone]


#13101

FromJafar <jafar@marti-orbak.nl>
Date2020-10-15 02:19 -0700
Message-ID<4d3e2806-49a5-4168-bb66-43a81f44f74cn@googlegroups.com>
In reply to#13098
Op woensdag 7 oktober 2020 om 13:02:12 UTC+2 schreef Wolfgang Riedmann:
> Hi Jafar, 
> 
> of course is that possible. 
> Create a subclass, and in the Init() method of this class you can 
> create your label. 
> 
> The following code creates a pushbutton after a SingleLineEdit control: 
> 
> method Init( oOwner, nID, oPoint, oDimension, kStyle ) class LookupSLE 
> Super:Init( oOwner, nID, oPoint, oDimension, kStyle ) 
> _oPB := LookupPB{ self, self:ControlId + 300 } 
> _oPB:HyperLabel := HyperLabel{ self:Name + "_LOOKUP", "...", ; 
> "", "" } 
> return self 
> 
> HTH 
> 
> Wolfgang
> > I am maintaining a VO app where the default behavior of a checkbox is 
> > limited to the checkbox rectangle itself. 
> > 
> > The way this is done however is by adding an additional label that is 
> > not part of the checkbox itself. 
> > 
> > Is there a simple way to avoid having to do this through a simple 
> > property/method without having to create additional labels all the 
> > time?
> --

This seems to complicated due to all the bindings that need to be set up for this to work.
Isn't there a better way to do this? Maybe a method that is notified automatically with the mouse coordinates so I can check the clicked area?

[toc] | [prev] | [next] | [standalone]


#13102

FromRobert Pope <cooeee@gmail.com>
Date2020-10-15 03:23 -0700
Message-ID<d2773f03-bf4b-4b26-8bdb-c0c2085b7f49o@googlegroups.com>
In reply to#13101
On Thursday, October 15, 2020 at 8:19:56 PM UTC+11, Jafar wrote:
> Op woensdag 7 oktober 2020 om 13:02:12 UTC+2 schreef Wolfgang Riedmann:
> > Hi Jafar, 
> > 
> > of course is that possible. 
> > Create a subclass, and in the Init() method of this class you can 
> > create your label. 
> > 
> > The following code creates a pushbutton after a SingleLineEdit control: 
> > 
> > method Init( oOwner, nID, oPoint, oDimension, kStyle ) class LookupSLE 
> > Super:Init( oOwner, nID, oPoint, oDimension, kStyle ) 
> > _oPB := LookupPB{ self, self:ControlId + 300 } 
> > _oPB:HyperLabel := HyperLabel{ self:Name + "_LOOKUP", "...", ; 
> > "", "" } 
> > return self 
> > 
> > HTH 
> > 
> > Wolfgang
> > > I am maintaining a VO app where the default behavior of a checkbox is 
> > > limited to the checkbox rectangle itself. 
> > > 
> > > The way this is done however is by adding an additional label that is 
> > > not part of the checkbox itself. 
> > > 
> > > Is there a simple way to avoid having to do this through a simple 
> > > property/method without having to create additional labels all the 
> > > time?
> > --
> 
> This seems to complicated due to all the bindings that need to be set up for this to work.
> Isn't there a better way to do this? Maybe a method that is notified automatically with the mouse coordinates so I can check the clicked area?

Your question seems a bit confusing. Your title is "Is there a simple property/method to ignore label of a checkbox?" and now you are asking how to can detect clicks to that area?

[toc] | [prev] | [next] | [standalone]


#13103

FromJafar <jafar@marti-orbak.nl>
Date2020-10-15 04:42 -0700
Message-ID<392d6f01-1177-42b1-9550-514ca5d2d4abn@googlegroups.com>
In reply to#13102
Op donderdag 15 oktober 2020 om 12:23:04 UTC+2 schreef Robert Pope:
> On Thursday, October 15, 2020 at 8:19:56 PM UTC+11, Jafar wrote: 
> > Op woensdag 7 oktober 2020 om 13:02:12 UTC+2 schreef Wolfgang Riedmann: 
> > > Hi Jafar, 
> > > 
> > > of course is that possible. 
> > > Create a subclass, and in the Init() method of this class you can 
> > > create your label. 
> > > 
> > > The following code creates a pushbutton after a SingleLineEdit control: 
> > > 
> > > method Init( oOwner, nID, oPoint, oDimension, kStyle ) class LookupSLE 
> > > Super:Init( oOwner, nID, oPoint, oDimension, kStyle ) 
> > > _oPB := LookupPB{ self, self:ControlId + 300 } 
> > > _oPB:HyperLabel := HyperLabel{ self:Name + "_LOOKUP", "...", ; 
> > > "", "" } 
> > > return self 
> > > 
> > > HTH 
> > > 
> > > Wolfgang 
> > > > I am maintaining a VO app where the default behavior of a checkbox is 
> > > > limited to the checkbox rectangle itself. 
> > > > 
> > > > The way this is done however is by adding an additional label that is 
> > > > not part of the checkbox itself. 
> > > > 
> > > > Is there a simple way to avoid having to do this through a simple 
> > > > property/method without having to create additional labels all the 
> > > > time? 
> > > -- 
> > 
> > This seems to complicated due to all the bindings that need to be set up for this to work. 
> > Isn't there a better way to do this? Maybe a method that is notified automatically with the mouse coordinates so I can check the clicked area?
> Your question seems a bit confusing. Your title is "Is there a simple property/method to ignore label of a checkbox?" and now you are asking how to can detect clicks to that area?

There does not seem to be a property or method that can be directly used, so to solve my problem Wolfgang suggested a workaround.
The solution provided by Wolfgang Riedmann however, works as long as I don't have to worry about the configured checkbox style, visibility etc.
So rather than relying on a runtime control, I figured it would be much easier to suppress mouse events when outside click area & I already achieved this by overriding the MouseButtonUp method from the Control class:

CLASS MC_CheckBox INHERIT CheckBox
	...
	DECLARE METHOD _IsMouseEventInClickableArea
METHOD _IsMouseEventInClickableArea(mouseEvent AS MouseEvent) AS LOGIC STRICT CLASS MC_CheckBox
	
	LOCAL mousePosition               := mouseEvent:Position                                      AS Point
	LOCAL currentPosition             := SELF:Origin                                              AS Point
	LOCAL currentSize                 := SELF:Size                                                AS Dimension
	LOCAL isMouseEventInClickableArea := mousePosition:X < currentPosition:X + currentSize:Height AS LOGIC
	
RETURN isMouseEventInClickableArea
METHOD MouseButtonUp(oMouseEvent) CLASS MC_CheckBox
	
	LOCAL mouseEvent := oMouseEvent AS MouseEvent
	
	IF SELF:IsReadOnly() .OR. SELF:IsDisabled .OR. SELF:_IsMouseEventInClickableArea(mouseEvent)
		RETURN SUPER:MouseButtonUp(mouseEvent)
	ELSE
		SELF:Checked := !SELF:Checked
	ENDIF
	
RETURN NIL

Its a bit more code than a simple property/method, but it solves my problem.

[toc] | [prev] | [next] | [standalone]


#13105

FromJafar <jafar@marti-orbak.nl>
Date2020-10-15 06:10 -0700
Message-ID<84abacd3-1648-4064-a07f-9b76ab33ca74n@googlegroups.com>
In reply to#13103
Op donderdag 15 oktober 2020 om 13:42:15 UTC+2 schreef Jafar:
> Op donderdag 15 oktober 2020 om 12:23:04 UTC+2 schreef Robert Pope:
> > On Thursday, October 15, 2020 at 8:19:56 PM UTC+11, Jafar wrote: 
> > > Op woensdag 7 oktober 2020 om 13:02:12 UTC+2 schreef Wolfgang Riedmann: 
> > > > Hi Jafar, 
> > > > 
> > > > of course is that possible. 
> > > > Create a subclass, and in the Init() method of this class you can 
> > > > create your label. 
> > > > 
> > > > The following code creates a pushbutton after a SingleLineEdit control: 
> > > > 
> > > > method Init( oOwner, nID, oPoint, oDimension, kStyle ) class LookupSLE 
> > > > Super:Init( oOwner, nID, oPoint, oDimension, kStyle ) 
> > > > _oPB := LookupPB{ self, self:ControlId + 300 } 
> > > > _oPB:HyperLabel := HyperLabel{ self:Name + "_LOOKUP", "...", ; 
> > > > "", "" } 
> > > > return self 
> > > > 
> > > > HTH 
> > > > 
> > > > Wolfgang 
> > > > > I am maintaining a VO app where the default behavior of a checkbox is 
> > > > > limited to the checkbox rectangle itself. 
> > > > > 
> > > > > The way this is done however is by adding an additional label that is 
> > > > > not part of the checkbox itself. 
> > > > > 
> > > > > Is there a simple way to avoid having to do this through a simple 
> > > > > property/method without having to create additional labels all the 
> > > > > time? 
> > > > -- 
> > > 
> > > This seems to complicated due to all the bindings that need to be set up for this to work. 
> > > Isn't there a better way to do this? Maybe a method that is notified automatically with the mouse coordinates so I can check the clicked area? 
> > Your question seems a bit confusing. Your title is "Is there a simple property/method to ignore label of a checkbox?" and now you are asking how to can detect clicks to that area?
> There does not seem to be a property or method that can be directly used, so to solve my problem Wolfgang suggested a workaround. 
> The solution provided by Wolfgang Riedmann however, works as long as I don't have to worry about the configured checkbox style, visibility etc. 
> So rather than relying on a runtime control, I figured it would be much easier to suppress mouse events when outside click area & I already achieved this by overriding the MouseButtonUp method from the Control class: 
> 
> CLASS MC_CheckBox INHERIT CheckBox 
> ... 
> DECLARE METHOD _IsMouseEventInClickableArea 
> METHOD _IsMouseEventInClickableArea(mouseEvent AS MouseEvent) AS LOGIC STRICT CLASS MC_CheckBox 
> 
> LOCAL mousePosition := mouseEvent:Position AS Point 
> LOCAL currentPosition := SELF:Origin AS Point 
> LOCAL currentSize := SELF:Size AS Dimension 
> LOCAL isMouseEventInClickableArea := mousePosition:X < currentPosition:X + currentSize:Height AS LOGIC 
> 
> RETURN isMouseEventInClickableArea 
> METHOD MouseButtonUp(oMouseEvent) CLASS MC_CheckBox 
> 
> LOCAL mouseEvent := oMouseEvent AS MouseEvent 
> 
> IF SELF:IsReadOnly() .OR. SELF:IsDisabled .OR. SELF:_IsMouseEventInClickableArea(mouseEvent) 
> RETURN SUPER:MouseButtonUp(mouseEvent) 
> ELSE 
> SELF:Checked := !SELF:Checked 
> ENDIF 
> 
> RETURN NIL 
> 
> Its a bit more code than a simple property/method, but it solves my problem.

In case anyone else comes across the same problem I had, there is a bug in the solution I found:
> isMouseEventInClickableArea := mousePosition:X < currentPosition:X + currentSize:Height

needs to be
isMouseEventInClickableArea :=  mousePosition:X < currentSize:Height

Since the mouse coordinates passed to MouseButtonUp seems to be local coordinates, rather than window coordinates.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.clipper.visual-objects


csiph-web