Sublime Forum

Show_input_panel enter key behavior?

#1

I have a user plugin that leverages the show_input_panel to capture user data entry. I recently updated to Build 4121, no other changes, but now the {enter} key appends a newline instead of submitting user input! How do I correct this?

0 Likes

Impossible to create new folder within ST4
#2

What platform & OS are you on ? Does it happen in safe mode i.e. Start safe mode, copy your plugin to safe mode & then check the behavior of enter.

0 Likes

#4

In Sublime Text 3, it’s hard coded that the enter key enters text in input widgets such as the input panel, the command palette, etc. In Sublime Text 4 that was changed to use a new command named select, which needs to be bound to a key to function. This allows for more flexiblity; for example a plugin can invoke the command to submit text, which was previously not possible.

A situation in which pressing enter just inserts a newline is characteristic of a key binding issue. In particular, it means that you have created an override on the default key bindings file, which locks it into the version from Sublime Text 3 and blocks new bindings.

You can verify by using Safe Mode as @UltraInstinct05 mentioned above.

Additionally, Preferences > Browse Packages from the menu; in the folder that appears, do you see a folder named Default, and if so, does it have sublime-keymap files in it? If yes, those files are the source of the problem. Moving the Default folder away (e.g. to your desktop) will remove the overrides.

0 Likes

Pressing enter in dialogs
#5

I’m on macOS Big Sur 11.6…

In the Browse Packages > Default, there is Default (OSX).sublime-keymap, but it has a last-mod date of 2020-09-27. I quickly reviewed and not really seeing any entries bound to [“enter”] with a relevant context.

Grrr. Works fine in safe mode! Ok, the digging continues!

0 Likes

#6

The point is that if the file exists, that file is used instead of the one that ships with Sublime Text 4. ST4 has bindings in it like this one that allow enter to execute the select command in the input panel:

	{ "keys": ["enter"], "command": "select", "context":
		[
			{ "key": "panel_has_focus", "operator": "equal", "operand": true },
			{ "key": "panel_type", "operand": "input"},
		],
	},

Without that binding (and may similar ones), the enter key does what the enter key does; it inserts a newline.

Safe Mode entirely ignores everything in your Packages folder (among other things), so it’s mimicing what happens if you remove that file to allow the new defaults to take effect again.

1 Like

#7

I removed the bindings file from Default, and that resolved the issue as you suggested. I note that my custom bindings are present, too. Thanks!

0 Likes