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

Dynamically change keyboard position on keyset change #547

Closed
Gingol opened this issue Apr 6, 2017 · 3 comments
Closed

Dynamically change keyboard position on keyset change #547

Gingol opened this issue Apr 6, 2017 · 3 comments

Comments

@Gingol
Copy link

Gingol commented Apr 6, 2017

Hi,
I would like to dynamically change the position of the keyboard when the keyset is changed.
I have this custom layout with three keyset:

layout: 'custom',
customLayout: {
	'meta_num': [
		'* / + -',
		'7 8 9 {b}',
		'4 5 6 .',
		'1 2 3 ,',
		'{meta_shift} 0 {normal} {e}'
	],
	'normal': [
		'q w e r t y u i o p {b}',
		'a s d f g h j k l {e}',
		'z x c v b n m , .',
		'{meta_shift} {space} {meta_num}'
	],
	'meta_shift': [
		'Q W E R T Y U I O P {b}',
		'A S D F G H J K L {e}',
		'Z X C V B N M ; :',
		'{normal} {space} {meta_num}'
	]
},

And this position settings:

reposition : true,
	position : {
		of : $("body"),
		my : 'center middle',
		at : 'center middle',
		at2: 'center bottom' // used when "usePreview" is false
},

The meta_num keyset is tighter than the other ones, so when the keyset changes the keyboard isn't centered but it's on the left (because the attributes "top" and "left" remain the same).
I would like an always-centered keyboards or alternatively the meta_num keyboard aligned on the right.
I already tried the redraw function but it didn't work.
I hope someone can help me.
Thanks in advance.

Mauro

@Mottie
Copy link
Owner

Mottie commented Apr 6, 2017

Hi @Gingol!

The redraw method will work, but was intended for a layout change. In issue #532 I shared a demo with custom keys that changed both the layout and language of the keyboard. I updated the demo to include a numpad with the custom keys included - demo.

In your case, only the keyset is being changed and the keyboard isn't being repositioned. This is definitely a bug which I'll fix in the next patch. In the mean time you can use this workaround to center the keyboard after a keyset change (demo):

$('#keyboard').on('keysetChange', function() {
  $(window).resize();
});

@Gingol
Copy link
Author

Gingol commented Apr 6, 2017

Hi @Mottie,
I came to the same solution by reading exactly that issue.
Thanks anyway for your answer.

@Mottie Mottie closed this as completed in d6ff147 Apr 6, 2017
@Mottie
Copy link
Owner

Mottie commented Apr 6, 2017

The fix will be available in the next update, but is currently available in the master branch.

I also added a new reposition method will allows you to call the function instead of triggering a window resize.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants