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
232 stars 16 forks source link

When the label is draggable, it couldn't response the OnDoubleClick event. #45

Closed dynamicboy closed 3 months ago

dynamicboy commented 9 months ago

Version: 2.8.8 Details: Step1: Drag a label onto the form Step2: In order to see the region of the label, set the background color to a non-transparent color. Step3: In form code editor, input codes as below:

Geometrics.AllowDrag(Label1)

'------------------------------------------------
Sub Label1_OnDoubleClick()
   TW.WriteLine("You double clicked the label")
EndSub

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

Step4: Run the form Result: No matter how I click the label, the OnDoubleClick event will never be arised.

Screenshot: 2024-01-05_170832

dynamicboy commented 9 months ago

BTW, is there any way to set z-index of label? Previously added label will be covered by upcoming labels.

VBAndCs commented 9 months ago

I am looking into the double click issue. The code of the Geometric library is written with sVB and you can find it in the samples folder. It seems to have no issue to cause this!. I will look into the sVB lib to trace the code, but now the electricity has went out and this work is on my PC Regarding the z index, in the form designer, right click any control and from the context menu use the Send to back or Bring to front command

Get Outlook for Androidhttps://aka.ms/AAb9ysg


From: dynamicboy @.> Sent: Friday, January 5, 2024 11:10:34 AM To: VBAndCs/sVB-Small-Visual-Basic @.> Cc: Subscribed @.***> Subject: [VBAndCs/sVB-Small-Visual-Basic] When the label is draggable, it couldn't response the OnDoubleClick event. (Issue #45)

Version: 2.8.8 Details: Step1: Drag a label onto the form Step2: In order to see the region of the label, set the background color to a non-transparent color. Step3: In form code editor, input codes as below:

Geometrics.AllowDrag(Label1)

'------------------------------------------------ Sub Label1_OnDoubleClick() TW.WriteLine("You double clicked the label") EndSub

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

Step4: Run the form Result: No matter how I click the label, the OnDoubleClick event will never be arised.

Screenshot: 2024-01-05_170832.png (view on web)https://github.com/VBAndCs/sVB-Small-Visual-Basic/assets/7421525/b8ea2fa4-2b7c-450b-9b7f-2885d6e48d41

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

dynamicboy commented 9 months ago

@VBAndCs I've noticed the way the form designer brings controls to the front and sends them back. I use the label and its append link function to create a quick launch application. I want to be able to drag some labels together and group them into a particular category. All these labels are added by code, and when I drag a previously added label around, it goes underneath and is stopped by labels added afterwards.

In my other keyboard type exercise application, the image of every key pressed on the keyboard needs to be displayed and animated to the center on top of any other labels as a much bigger preview label.

键盘

VBAndCs commented 9 months ago

I added the BringToFront and SendToBack methods to the controls (wait for the next update).

I discovered the AllowDrag issue. It is a side effect of allowing only one handler for each control! There is no double click event, but I use the PreviewLeftMouseDown to raise the double click if the mouse is clicked twice! And when the AllowDrag method registers a handler for the PreviewLeftMouseDown, it overwrites the one used for the DoubleClick event! This is a complicated system so that every change breaks something! I will try to fix this issue.


From: dynamicboy @.> Sent: Friday, January 5, 2024 1:51 PM To: VBAndCs/sVB-Small-Visual-Basic @.> Cc: Mohammad Hamdy Ghanem @.>; Mention @.> Subject: Re: [VBAndCs/sVB-Small-Visual-Basic] When the label is draggable, it couldn't response the OnDoubleClick event. (Issue #45)

@VBAndCshttps://github.com/VBAndCs I've noticed the way the form designer brings controls to the front and sends them back. I use the label and its append link function to create a quick launch application. I want to be able to drag some labels together and group them into a particular category. All these labels are added by code, and when I drag a previously added label around, it goes underneath and is stopped by labels added afterwards.

In my other keyboard type exercise application, the image of every key pressed on the keyboard needs to be displayed and animated to the center on top of any other labels as a much bigger preview label.

default.png (view on web)https://github.com/VBAndCs/sVB-Small-Visual-Basic/assets/7421525/50c0c268-dab4-460f-96a7-f158b481768c

— Reply to this email directly, view it on GitHubhttps://github.com/VBAndCs/sVB-Small-Visual-Basic/issues/45#issuecomment-1878691587, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ALQ5MVUM46TTX7EIO5Y4XL3YNAAMTAVCNFSM6AAAAABBOED3POVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNZYGY4TCNJYG4. You are receiving this because you were mentioned.Message ID: @.***>

VBAndCs commented 9 months ago

I managed to fix it. Thee OnDoubleClick and OnMouseLeftDown events now will not overwrite each other, and more importantly, I allowed to register more than one handler for the same event if they belong to different libraries. For example, the Geometrics.AllowDrag(Label1) handles the OnMouseLeftDown and OnMouseMove events of Label1, but if you add handlers for these events of label1 in your program, they will not cancel the handlers added by the Geometrics.AllowDrag. In short, handlers of each library are isolated from each other and from your program, so that each of them can ad one handler per event in its domain. I've published these fixed and you can try them in the sVB 2.98.8.1: https://marketplace.visualstudio.com/items?itemName=ModernVBNET.sVBInstaller


From: dynamicboy @.> Sent: Friday, January 5, 2024 1:51 PM To: VBAndCs/sVB-Small-Visual-Basic @.> Cc: Mohammad Hamdy Ghanem @.>; Mention @.> Subject: Re: [VBAndCs/sVB-Small-Visual-Basic] When the label is draggable, it couldn't response the OnDoubleClick event. (Issue #45)

@VBAndCshttps://github.com/VBAndCs I've noticed the way the form designer brings controls to the front and sends them back. I use the label and its append link function to create a quick launch application. I want to be able to drag some labels together and group them into a particular category. All these labels are added by code, and when I drag a previously added label around, it goes underneath and is stopped by labels added afterwards.

In my other keyboard type exercise application, the image of every key pressed on the keyboard needs to be displayed and animated to the center on top of any other labels as a much bigger preview label.

default.png (view on web)https://github.com/VBAndCs/sVB-Small-Visual-Basic/assets/7421525/50c0c268-dab4-460f-96a7-f158b481768c

— Reply to this email directly, view it on GitHubhttps://github.com/VBAndCs/sVB-Small-Visual-Basic/issues/45#issuecomment-1878691587, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ALQ5MVUM46TTX7EIO5Y4XL3YNAAMTAVCNFSM6AAAAABBOED3POVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNZYGY4TCNJYG4. You are receiving this because you were mentioned.Message ID: @.***>

VBAndCs commented 9 months ago

Note that you can now safely add and remove event handlers at runtime. To remove a handler, just use an empty sub to handle it, and this will cancel the old handler. For example:


'------------------------------------------------
Sub BtnAddHandler_OnClick()
   Me.OnClick = OnClick
EndSub

'------------------------------------------------
Sub OnClick()
   Me.ShowMessage("Form is clickeed", "!")
EndSub

'------------------------------------------------
Sub BtnRemoveHandler_OnClick()
   Me.OnClick = NoHandler
EndSub

Sub NoHandler()
   ' Do nothing
EndSub

From: dynamicboy @.> Sent: Friday, January 5, 2024 1:51 PM To: VBAndCs/sVB-Small-Visual-Basic @.> Cc: Mohammad Hamdy Ghanem @.>; Mention @.> Subject: Re: [VBAndCs/sVB-Small-Visual-Basic] When the label is draggable, it couldn't response the OnDoubleClick event. (Issue #45)

@VBAndCshttps://github.com/VBAndCs I've noticed the way the form designer brings controls to the front and sends them back. I use the label and its append link function to create a quick launch application. I want to be able to drag some labels together and group them into a particular category. All these labels are added by code, and when I drag a previously added label around, it goes underneath and is stopped by labels added afterwards.

In my other keyboard type exercise application, the image of every key pressed on the keyboard needs to be displayed and animated to the center on top of any other labels as a much bigger preview label.

default.png (view on web)https://github.com/VBAndCs/sVB-Small-Visual-Basic/assets/7421525/50c0c268-dab4-460f-96a7-f158b481768c

— Reply to this email directly, view it on GitHubhttps://github.com/VBAndCs/sVB-Small-Visual-Basic/issues/45#issuecomment-1878691587, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ALQ5MVUM46TTX7EIO5Y4XL3YNAAMTAVCNFSM6AAAAABBOED3POVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNZYGY4TCNJYG4. You are receiving this because you were mentioned.Message ID: @.***>