Skip to content

fixes crash when editing input fields #8

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

Merged
merged 1 commit into from
Sep 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions flutter/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ const (
TextUpdateStateMethod = "TextInputClient.updateEditingState"

// text
SetClientMethod = "TextInput.setClient"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should add a updateState method to textModel and handle all these methods in there.

ClearClientMethod = "TextInput.clearClient"
SetEditingStateMethod = "TextInput.setEditingState"
TextInputClientSet = "TextInput.setClient"
TextInputClientClear = "TextInput.clearClient"
TextInputSetEditState = "TextInput.setEditingState"
)

// Message is the json content of a PlatformMessage
Expand Down
18 changes: 8 additions & 10 deletions gutter.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,26 +271,24 @@ func onPlatformMessage(platMessage flutter.PlatformMessage, window unsafe.Pointe
}

if platMessage.Channel == flutter.TextInputChannel {

if message.Method == flutter.ClearClientMethod {
switch message.Method {
case flutter.TextInputClientClear:
state.clientID = 0
}

if message.Method == flutter.SetClientMethod {
case flutter.TextInputClientSet:
var body []interface{}
json.Unmarshal(message.Args, &body)
state.clientID = body[0].(float64)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

facepalm why couldn't they just include the ID in the initial structure? lol

}

if message.Method == flutter.SetEditingStateMethod {
case flutter.TextInputSetEditState:
if state.clientID != 0 {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure this check is strictly necessary. but left it in anyways.

editingState := flutter.ArgsEditingState{}
json.Unmarshal(message.Args, &editingState)
state.word = editingState.Text
state.selectionBase = editingState.SelectionBase
state.selectionExtent = editingState.SelectionExtent
}

default:
// log.Printf("unhandled text input method: %#v\n", platMessage.Message)
}

}

return true
Expand Down