This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2010-11-14 19:12:29

irobot
New Scratcher
Registered: 2010-10-25
Posts: 4

Stopping the enter key from restarting a project.

Is there a way to stop the enter key from restarting a project?
The problem is that when I take user input, if the user hits "Enter" when the dialog box is not up the program restarts.
Thanks, Dave

Offline

 

#2 2010-11-14 19:15:20

12three
Scratcher
Registered: 2008-06-12
Posts: 1000+

Re: Stopping the enter key from restarting a project.

Not much of a problem for me.
I don't think there's a way to change that though. It might not happen with panther and some of the other mods.

Offline

 

#3 2010-11-14 19:33:08

fullmoon
Retired Community Moderator
Registered: 2007-06-04
Posts: 1000+

Re: Stopping the enter key from restarting a project.

The enter key doesn't necessarily restart the project, it just runs all the green-flag scripts. For this reason, I would recommend avoiding the "When flag pressed" hat as much as possible. Instead, start all your scripts with "When I receive [startProject]". Then add a single script to trigger all of these scripts:

Code:

When flag clicked:
  broadcast [startProject]

This can be improved upon to prevent the enter key from doing anything. Create a variable called "runAlready" and use this script:

Code:

When flag clicked:
  if <runAlready = 0>
    change runAlready by 1
    broadcast [startProject]

That way, [startProject] is only broadcasted once, unless the runAlready variable is reset. Hope this helps!


http://i302.photobucket.com/albums/nn100/fullmoon32/wow.jpg

Offline

 

#4 2010-11-14 20:09:45

OldWheezerGeezer
Scratcher
Registered: 2010-06-04
Posts: 500+

Re: Stopping the enter key from restarting a project.

woah! i never noticed that...

O_o

just had my mind blown...

Offline

 

#5 2010-11-15 01:12:23

irobot
New Scratcher
Registered: 2010-10-25
Posts: 4

Re: Stopping the enter key from restarting a project.

fullmoon wrote:

The enter key doesn't necessarily restart the project, it just runs all the green-flag scripts. For this reason, I would recommend avoiding the "When flag pressed" hat as much as possible. Instead, start all your scripts with "When I receive [startProject]". Then add a single script to trigger all of these scripts:

Code:

When flag clicked:
  broadcast [startProject]

This can be improved upon to prevent the enter key from doing anything. Create a variable called "runAlready" and use this script:

Code:

When flag clicked:
  if <runAlready = 0>
    change runAlready by 1
    broadcast [startProject]

That way, [startProject] is only broadcasted once, unless the runAlready variable is reset. Hope this helps!

Thanks fullmoon- I tried this but it causes the program to hang if the player presses "enter" twice by acccident when using the "ASK" to get keyboard input.
Thanks, Dave

Offline

 

#6 2010-11-15 08:03:49

fullmoon
Retired Community Moderator
Registered: 2007-06-04
Posts: 1000+

Re: Stopping the enter key from restarting a project.

irobot wrote:

fullmoon wrote:

The enter key doesn't necessarily restart the project, it just runs all the green-flag scripts. For this reason, I would recommend avoiding the "When flag pressed" hat as much as possible. Instead, start all your scripts with "When I receive [startProject]". Then add a single script to trigger all of these scripts:

Code:

When flag clicked:
  broadcast [startProject]

This can be improved upon to prevent the enter key from doing anything. Create a variable called "runAlready" and use this script:

Code:

When flag clicked:
  if <runAlready = 0>
    change runAlready by 1
    broadcast [startProject]

That way, [startProject] is only broadcasted once, unless the runAlready variable is reset. Hope this helps!

Thanks fullmoon- I tried this but it causes the program to hang if the player presses "enter" twice by acccident when using the "ASK" to get keyboard input.
Thanks, Dave

Actually, that glitch appears to be universal. Try a project that uses a lot of green-flag hats and then test the "ask" block...the same thing will happen.


http://i302.photobucket.com/albums/nn100/fullmoon32/wow.jpg

Offline

 

#7 2010-11-15 08:06:51

fullmoon
Retired Community Moderator
Registered: 2007-06-04
Posts: 1000+

Re: Stopping the enter key from restarting a project.

The other thing I would suggest is having a splash sprite shown whenever the user opens the project that you can click to trigger all the other scripts.


http://i302.photobucket.com/albums/nn100/fullmoon32/wow.jpg

Offline

 

#8 2010-11-15 12:17:25

irobot
New Scratcher
Registered: 2010-10-25
Posts: 4

Re: Stopping the enter key from restarting a project.

fullmoon wrote:

The other thing I would suggest is having a splash sprite shown whenever the user opens the project that you can click to trigger all the other scripts.

Ok, thanks!

Offline

 

Board footer