VBAndCs / sVB-Small-Visual-Basic

Small Visual Basic (sVB) is an educational programming language, created by Eng. Mohammad Hamdy as an evolved version of Microsoft Small Basic (SB). It is meant to be easier and more powerful at the same time, to introduce programming basics to kids and beginners of any age, provided that they can use the English keyboard on the Windows OS.
Other
222 stars 16 forks source link

Colors.None and Colors.Transparent could be weired sometime. #44

Closed dynamicboy closed 1 month ago

dynamicboy commented 6 months ago

Version: 2.8.8 Details: Step1: Drag a label and a button onto the form Step2: In order to see their region, give them a visible solid border color, bigger fontsize (16) and bold fontstyle. Step3: In form code editor, input some codes as below:

'Form1.BackColor = Colors.Transparent

'Label1.BackColor = Colors.Transparent
'Button1.BackColor = Colors.Transparent

Label1.BackColor = Colors.None
Button1.BackColor = Colors.None

'------------------------------------------------
Sub Form1_OnClick()
   TW.WriteLine("You just clicked the form")
EndSub

'------------------------------------------------
Sub Label1_OnClick()
   TW.WriteLine("You just clicked the label")
EndSub

'------------------------------------------------
Sub Button1_OnClick()
   TW.WriteLine("You just clicked the button")
EndSub

Step3: Run the form Result:

  1. The space in the border inner region couldn't be clicked, which is correct according to Colors.None description. But The texts of label and button also couldn't be clicked, then the control is useless.
  2. Sometimes when the mouse pointer enter the region of the button, the original backcolor (maybe the hover background color) will appear,

if change the code to:

'Form1.BackColor = Colors.Transparent

Label1.BackColor = Colors.Transparent
Button1.BackColor = Colors.Transparent

'Label1.BackColor = Colors.None
'Button1.BackColor = Colors.None

'------------------------------------------------
Sub Form1_OnClick()
   TW.WriteLine("You just clicked the form")
EndSub

'------------------------------------------------
Sub Label1_OnClick()
   TW.WriteLine("You just clicked the label")
EndSub

'------------------------------------------------
Sub Button1_OnClick()
   TW.WriteLine("You just clicked the button")
EndSub

it's OK, according to the Colors.Transparent description(see through, clickable)

Weired thing happpens when I turn the form background transparent: Code:

Form1.BackColor = Colors.Transparent

Label1.BackColor = Colors.Transparent
Button1.BackColor = Colors.Transparent

'Label1.BackColor = Colors.None
'Button1.BackColor = Colors.None

'------------------------------------------------
Sub Form1_OnClick()
   TW.WriteLine("You just clicked the form")
EndSub

'------------------------------------------------
Sub Label1_OnClick()
   TW.WriteLine("You just clicked the label")
EndSub

'------------------------------------------------
Sub Button1_OnClick()
   TW.WriteLine("You just clicked the button")
EndSub

Result:

  1. The transparent area of the two controls can be see through, but couldn't be clicked.(Not OK, it should be clickable)
  2. The texts and border of label can be clicked. (OK, the lable is accessable by mouse)
  3. When the mouse pointer moves into the text pixels of the button, the hover background color will appear.(Not OK, it should stays transparent)
VBAndCs commented 6 months ago

When I changed the event system, I prevented the text block that shows the title of labels and buttons from receiving mouse clicks, and this is the cause of none responding label when its back color is none. I will roll back this change to fix the issue. Regarding the button back color under mouse, this is because wpf buttons use a hover style. Changing this behavior needs to change the button template: https://stackoverflow.com/questions/17259280/how-do-you-change-background-for-a-button-mouseover-in-wpf

You can apply this by using the Control.SetStyle method. See info about at the book, and try the templates from the above link. There is a sample named custom styles in the sVB samples folder. I opened this back door to encourage developers to learn about Xaml. I have no intention currently to change the button behavior directly in sVB.


From: dynamicboy @.> Sent: Friday, January 5, 2024 10:59:18 AM To: VBAndCs/sVB-Small-Visual-Basic @.> Cc: Subscribed @.***> Subject: [VBAndCs/sVB-Small-Visual-Basic] Colors.None and Colors.Transparent could be weired sometime. (Issue #44)

Version: 2.8.8 Details: Step1: Drag a label and a button onto the form Step2: In order to see their region, give them a visible solid border color, bigger fontsize (16) and bold fontstyle. Step3: In form code editor, input some codes as below:

'Form1.BackColor = Colors.Transparent

'Label1.BackColor = Colors.Transparent 'Button1.BackColor = Colors.Transparent

Label1.BackColor = Colors.None Button1.BackColor = Colors.None

'------------------------------------------------ Sub Form1_OnClick() TW.WriteLine("You just clicked the form") EndSub

'------------------------------------------------ Sub Label1_OnClick() TW.WriteLine("You just clicked the label") EndSub

'------------------------------------------------ Sub Button1_OnClick() TW.WriteLine("You just clicked the button") EndSub

Step3: Run the form Result:

  1. The space in the border inner region couldn't be clicked, which is correct according to Colors.None description. But The texts of label and button also couldn't be clicked, then the control is useless.
  2. Sometimes when the mouse pointer enter the region of the button, the original backcolor (maybe the hover background color) will appear,

if change the code to:

'Form1.BackColor = Colors.Transparent

Label1.BackColor = Colors.Transparent Button1.BackColor = Colors.Transparent

'Label1.BackColor = Colors.None 'Button1.BackColor = Colors.None

'------------------------------------------------ Sub Form1_OnClick() TW.WriteLine("You just clicked the form") EndSub

'------------------------------------------------ Sub Label1_OnClick() TW.WriteLine("You just clicked the label") EndSub

'------------------------------------------------ Sub Button1_OnClick() TW.WriteLine("You just clicked the button") EndSub

it's OK, according to the Colors.Transparent description(see through, clickable)

Weired thing happpens when I turn the form background transparent: Code:

Form1.BackColor = Colors.Transparent

Label1.BackColor = Colors.Transparent Button1.BackColor = Colors.Transparent

'Label1.BackColor = Colors.None 'Button1.BackColor = Colors.None

'------------------------------------------------ Sub Form1_OnClick() TW.WriteLine("You just clicked the form") EndSub

'------------------------------------------------ Sub Label1_OnClick() TW.WriteLine("You just clicked the label") EndSub

'------------------------------------------------ Sub Button1_OnClick() TW.WriteLine("You just clicked the button") EndSub

Result:

  1. The transparent area of the two controls can be see through, but couldn't be clicked.(Not OK, it should be clickable)
  2. The texts and border of label can be clicked. (OK, the lable is accessable by mouse)
  3. When the mouse pointer moves into the text pixels of the button, the hover background color will appear.(Not OK, it should stays transparent)

— Reply to this email directly, view it on GitHubhttps://github.com/VBAndCs/sVB-Small-Visual-Basic/issues/44, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ALQ5MVW76LLTCXU6JHN4B3LYM66GNAVCNFSM6AAAAABBODV66OVHI2DSMVQWIX3LMV43ASLTON2WKOZSGA3DMOJWHAZDGMA. You are receiving this because you are subscribed to this thread.Message ID: @.***>