Debug Console (Visible, Scale)

  • Debug Console Settings
    If the settings are stored “globally”, and the user needs to switch between projects (to fix errors, improvements, additions, etc.) with different settings (permissions, platform, orientation (portrait, landscape)), then you need to remember and reconfigure the Debug Console. Saving the settings in a project ensures that the customized environment for a particular job is saved.
    But this can be achieved using nodes.
  • Shortcuts for Debug Console
    It is more convenient to store it “globally”, because most likely they will not change from project to project.

Therefore, it is necessary to decide how best to do it?
I’m waiting for an opinion, maybe someone else will speak…

Thanks for the info. I will try. :slight_smile:

1 Like

This problem is due to the fact that it is not the KeyCode that is processed, but the String.

Upgrade to KeyCode:

            // Toggle console
			kha.input.Keyboard.get().notify(null, function(key: kha.input.KeyCode) {
				// ~
				if (key == 16) visible = !visible;
				// [
				else if (key == 219) {
					debugFloat -= 0.1; 
					trace("debugFloat = "+ debugFloat);
					// Scale
					var debugScale = getScale() - 0.1;
					if (debugScale > 0.3) {
						setScale(debugScale);
					} 
				}
				// ]
				else if (key == 221) { 
					debugFloat += 0.1;
					trace("debugFloat = "+ debugFloat);
					// Scale
					var debugScale = getScale() + 0.1;
					if (debugScale < 10.0) {
						setScale(debugScale);
					} 
				}				
			}, null);
1 Like

Nice! To make the code a bit more readbable you can use the constants defined here: http://api.kha.tech/kha/input/KeyCode.html, so instead of 16 you can write KeyCode.Tilde (which btw isn’t 16 according to the API documentation)

1 Like

Thanks. I will correct. I made a mistake with the code, I printed the value of key to the console and I got 16 (this is Shift)

1 Like

To assign buttons as it is done in Keymap, you need to use EnumProperty with a list of required keys. But there are the following problems:

  1. to use event means without modifiers (Shift, Ctrl…) and this prevents the user from assigning ~ to hotkeys (with full_event - Blender crashes);
  2. it is necessary to take into account all keys in EnumProperty, otherwise if the user clicks one that is not included in the enumeration, then a message will be displayed in the console and it must be processed (you need to figure out how), but the button will be assigned in the interface;
  1. if you specify symbols (~, *, /…) as default values, they will not be displayed to the field. If you assign them, then everything will be fine. Also a strange situation:
    error_default

This post helped me a little to figure it out: python - What are the parameters event and full_event of UILayout are for? - Blender Stack Exchange

As a result, this method is not stable and you still need to understand and take a lot of into account. Therefore, I refuse this method.

Better to use a regular EnumProperty with predefined options (as in the Keyboard node). The option is simple and working =)

The result is like this:
dc_version

If satisfied, I will do PR.

Scripts: DebugConsole_v4.zip

2 Likes

That’s unfortunate but if this is how it’s working then your solution is better :slight_smile:

Looking forward to the PR, although you should probably move the shortcut UI into Armory’s user preferences as they are a global setting.

1 Like

Done:
dc_settings_v2

Scripts: DebugConsole_v5.zip

2 Likes