Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Controls.ButtonClicked event never be called when program has loop #125

Open
nonkit opened this issue Feb 19, 2020 · 2 comments
Open

Controls.ButtonClicked event never be called when program has loop #125

nonkit opened this issue Feb 19, 2020 · 2 comments
Labels
pri/1 Priority 1 - This isn't a crashing bug, but this is a critical functionality (likely parity) type/runtime Issues related to runtime engine

Comments

@nonkit
Copy link
Member

nonkit commented Feb 19, 2020

Controls.ButtoClicked event never be called when the program has a loop.
Sample code is:

' doesn't work with SBO 1.0
Not["True"] = "False"
Not["False"] = "True"
show = "True"
rect = Shapes.AddRectangle(100, 100)
Shapes.Move(rect, 100, 100)
GraphicsWindow.BrushColor = "Black"
Controls.AddButton("Toggle", 10, 10)
Controls.ButtonClicked = OnButtonClicked
While "True"
  If buttonClicked Then
    show = Not[show]
    If show Then
      Shapes.ShowShape(rect)
    Else
      Shapes.HideShape(rect)
    EndIf
    buttonClicked = "False"
  Else
    Program.Delay(500)
  EndIf
EndWhile

Sub OnButtonClicked
  buttonClicked = "True"
EndSub

Following debug screen shows the event handler is under the program in its call stack.
issue125event1

But following code (doesn't have a main loop) runs properly:

' works with SBO 1.0
Not["True"] = "False"
Not["False"] = "True"
show = "True"
rect = Shapes.AddRectangle(100, 100)
Shapes.Move(rect, 100, 100)
GraphicsWindow.BrushColor = "Black"
Controls.AddButton("Toggle", 10, 10)
Controls.ButtonClicked = OnButtonClicked

Sub OnButtonClicked
  show = Not[show]
  If show Then
    Shapes.ShowShape(rect)
  Else
    Shapes.HideShape(rect)
  EndIf
  buttonClicked = "False"
EndSub

In the case above, there are no Program in the call stack.
issue125event2

Following code is just a subroutine sample:

OnButtonClicked()

Sub OnButtonClicked
  buttonClicked = "True"
EndSub

This is just normal subroutine appearing on the main Program in the call stack.
issue125sub

@nonkit nonkit changed the title Controls.ButtonClicked event never be called when program has main loop Controls.ButtonClicked event never be called when program has loop Feb 19, 2020
@nonkit nonkit added the type/runtime Issues related to runtime engine label Feb 28, 2020
@Caseysch
Copy link
Contributor

Caseysch commented Jul 27, 2020

Minimum repro:

Controls.AddButton("Click", 10, 10)
Controls.ButtonClicked = OnButtonClicked

Sub OnButtonClicked
  TextWindow.WriteLine("subroutine called")
EndSub

' This loop prevents the subroutine from being called
While "True"
  Program.Delay(500)
EndWhile

@Caseysch Caseysch added the pri/2 Priority 2 - Should be done for current release, but it isn't as critical label Jul 27, 2020
@Caseysch Caseysch added pri/1 Priority 1 - This isn't a crashing bug, but this is a critical functionality (likely parity) and removed pri/2 Priority 2 - Should be done for current release, but it isn't as critical labels Jul 28, 2020
@Caseysch
Copy link
Contributor

Bumped up to pri/1: affects tutorial and probably most games

@AndrewCook AndrewCook removed their assignment Dec 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pri/1 Priority 1 - This isn't a crashing bug, but this is a critical functionality (likely parity) type/runtime Issues related to runtime engine
Projects
None yet
Development

No branches or pull requests

3 participants