Skip to content

Fix keyboard shortcut #383

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

Conversation

james-lawrence
Copy link
Contributor

turned out really easy to do the codepoint in go. I'm still in the processing of testing this code in my app. but if someone wants to take it for a spin, that'd be helpful.

int32(rune("f"))

that being said, currently my test doesn't work. some compilation issue I do not yet understand.

but here is how i generated the test:

package main

// #include "key-codepoint.cpp"
import "C"

import (
	"log"
	"strconv"

	"github.com/go-flutter-desktop/go-flutter"
)

func main() {
	examples := []rune("񃍃Cƅ񊘐f@~΍خ4vʤΌ񩂅-~ä诙ϝ٧婲Ћ鯄YT񯪪ψʈ»qѶƿւÃ槼ڧ󯺞덉!0羲򦜔🷚穰B룅챧ښшP鼥>򑽇ݚɴyţS°�鋯膴׾򾹭Ӿ𡕟Ϋl𙰳ﭼ򌚰Ѩ୺俐ֿ򙰳Ӱ9�榾Ȱsٶӎ隣#|ٯɕ򬠰#󤽹߹򱘂^C¢:Ȣ鎻㿸𗢴=M赧󐲯U̾32ҔަMߢ}.Ǒʸ󎋀�݂7񒳙콞dס󌢒򭂦䮁򔎩󭾆󡫚٦񈥑狳,_wܘ𯹸ق󾖘ӔȻWᓹ􉤀ۿҍF侹냊Ʌ>")
	result := make([]int32, 0, len(examples))
	for _, c := range examples {
		result = append(result, flutter.CodePointFromGLFWKey(c))
		log.Println(c, "==", codePointTest(c), "=", c == codePointTest(c) && c == flutter.CodePointFromGLFWKey(c), "(", flutter.CodePointFromGLFWKey(c), ")")

		if !(c == codePointTest(c) && c == flutter.CodePointFromGLFWKey(c)) {
			panic("invalid conversion")
		}
	}

	log.Println("results:")
	s := ""
	for _, i := range result {
		s += strconv.Itoa(int(i)) + ", "
	}
	log.Println("[", s, "]")
}

func codePointTest(r rune) (result int32) {
	return int32(C.GetUTF32CodePointFromGLFWKey2(C.CString(string(r))))
}

pchampio and others added 5 commits April 2, 2020 19:22
A little work-around.
Waiting for go-flutter-desktop#314
to have a real answer.

For now, I am a bit sceptical on how the keyboard text
selection/keyboard pasting will be handled in the flutter side.

I'm afraid it might not be suited to our need. We are sending
GLFW(linux) related event to the framework. But the framework only has
one handler, linux. This means, sending keyevent on darwin will not
support the correct keyboard layout (Ctrl -> Meta).

As those different keyboard layout are already supported in go-flutter,
this work-around ensure that we keep control of the textinput when
needed.
@james-lawrence james-lawrence force-pushed the fix_keyboard_shortcut branch 5 times, most recently from 824322c to c3ba78b Compare April 4, 2020 17:28
@james-lawrence james-lawrence force-pushed the fix_keyboard_shortcut branch from c3ba78b to 10e8496 Compare April 4, 2020 17:34
@pchampio
Copy link
Member

pchampio commented Apr 4, 2020

@james-lawrence thanks for your PR!
I'm applying other changes, regarding key-events.
Since it affect text navigation, it's a bit hard.

I did use some code of yours, bit I wont merge it using this PR.

@pchampio pchampio closed this Apr 4, 2020
@james-lawrence
Copy link
Contributor Author

;) i was just testing my changes. seems fine do you have a PR I can look at and use locally?

@pchampio
Copy link
Member

pchampio commented Apr 4, 2020

I'll update #338 in a second

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

Successfully merging this pull request may close these issues.

2 participants