Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit091ae98

Browse files
committed
Add TextInputHandler
1 parentcd749fe commit091ae98

File tree

4 files changed

+42
-13
lines changed

4 files changed

+42
-13
lines changed

‎flutter-plugins/src/platform.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub struct PlatformPlugin {
3232
}
3333

3434
implPlatformPlugin{
35-
pubfnnew(handler:Arc<Mutex<Box<dynPlatformHandler +Send>>>) ->Self{
35+
pubfnnew(handler:Arc<Mutex<dynPlatformHandler +Send>>) ->Self{
3636
Self{
3737
channel:Weak::new(),
3838
handler:Arc::new(RwLock::new(Handler{ handler})),
@@ -53,7 +53,7 @@ impl Plugin for PlatformPlugin {
5353
}
5454

5555
structHandler{
56-
handler:Arc<Mutex<Box<dynPlatformHandler +Send>>>,
56+
handler:Arc<Mutex<dynPlatformHandler +Send>>,
5757
}
5858

5959
implMethodCallHandlerforHandler{

‎flutter-plugins/src/textinput.rs

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,19 @@ use log::debug;
66
usesuper::prelude::*;
77

88
useself::text_editing_state::TextEditingState;
9+
use parking_lot::Mutex;
910

1011
mod text_editing_state;
1112

1213
pubconstPLUGIN_NAME:&str =module_path!();
1314
pubconstCHANNEL_NAME:&str ="flutter/textinput";
1415

16+
pubtraitTextInputHandler{
17+
fnshow(&mutself);
18+
19+
fnhide(&mutself);
20+
}
21+
1522
pubstructTextInputPlugin{
1623
channel:Weak<JsonMethodChannel>,
1724
handler:Arc<RwLock<Handler>>,
@@ -20,6 +27,7 @@ pub struct TextInputPlugin {
2027

2128
structHandler{
2229
data:Arc<RwLock<Data>>,
30+
handler:Arc<Mutex<dynTextInputHandler +Send>>,
2331
}
2432

2533
structData{
@@ -39,8 +47,8 @@ impl Plugin for TextInputPlugin {
3947
}
4048
}
4149

42-
implDefaultforTextInputPlugin{
43-
fndefault() ->Self{
50+
implTextInputPlugin{
51+
pubfnnew(handler:Arc<Mutex<dynTextInputHandler +Send>>) ->Self{
4452
let data =Arc::new(RwLock::new(Data{
4553
client_id:None,
4654
editing_state:None,
@@ -49,13 +57,12 @@ impl Default for TextInputPlugin {
4957
channel:Weak::new(),
5058
handler:Arc::new(RwLock::new(Handler{
5159
data:Arc::clone(&data),
60+
handler,
5261
})),
5362
data,
5463
}
5564
}
56-
}
5765

58-
implTextInputPlugin{
5966
fnwith_channel<F>(&self,f:F)
6067
where
6168
F:FnOnce(&dynMethodChannel),
@@ -122,8 +129,14 @@ impl MethodCallHandler for Handler {
122129
data.editing_state.replace(state);
123130
Ok(Value::Null)
124131
}
125-
"TextInput.show" =>Ok(Value::Null),
126-
"TextInput.hide" =>Ok(Value::Null),
132+
"TextInput.show" =>{
133+
self.handler.lock().show();
134+
Ok(Value::Null)
135+
}
136+
"TextInput.hide" =>{
137+
self.handler.lock().hide();
138+
Ok(Value::Null)
139+
}
127140
_ =>Err(MethodCallError::NotImplemented),
128141
}
129142
}

‎flutter-winit/src/handler.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use async_std::task;
44
use copypasta::{ClipboardContext,ClipboardProvider};
55
use flutter_engine::FlutterEngineHandler;
66
use flutter_plugins::platform::{AppSwitcherDescription,MimeError,PlatformHandler};
7+
use flutter_plugins::textinput::TextInputHandler;
78
use flutter_plugins::window::{PositionParams,WindowHandler};
89
use futures_task::FutureObj;
910
use glutin::event_loop::EventLoopProxy;
@@ -178,3 +179,17 @@ impl WindowHandler for WinitWindowHandler {
178179

179180
fnend_drag(&mutself){}
180181
}
182+
183+
pubstructWinitTextInputHandler{}
184+
185+
implDefaultforWinitTextInputHandler{
186+
fndefault() ->Self{
187+
Self{}
188+
}
189+
}
190+
191+
implTextInputHandlerforWinitTextInputHandler{
192+
fnshow(&mutself){}
193+
194+
fnhide(&mutself){}
195+
}

‎flutter-winit/src/window.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
usecrate::context::Context;
2-
usecrate::handler::{WinitFlutterEngineHandler,WinitPlatformHandler,WinitWindowHandler};
2+
usecrate::handler::{
3+
WinitFlutterEngineHandler,WinitPlatformHandler,WinitTextInputHandler,WinitWindowHandler,
4+
};
35
usecrate::keyboard::raw_key;
46
usecrate::pointer::Pointers;
57
use flutter_engine::channel::Channel;
@@ -63,14 +65,13 @@ impl FlutterWindow {
6365
let isolate_cb =move ||{
6466
proxy.send_event(FlutterEvent::IsolateCreated).ok();
6567
};
66-
let platform_handler =Arc::new(Mutex::new(Box::new(WinitPlatformHandler::new(
67-
context.clone(),
68-
)?)as_));
68+
let platform_handler =Arc::new(Mutex::new(WinitPlatformHandler::new(context.clone())?));
6969
let close =Arc::new(AtomicBool::new(false));
7070
let window_handler =Arc::new(Mutex::new(WinitWindowHandler::new(
7171
context.clone(),
7272
close.clone(),
7373
)));
74+
let textinput_handler =Arc::new(Mutex::new(WinitTextInputHandler::default()));
7475

7576
engine.add_plugin(DialogPlugin::default());
7677
engine.add_plugin(IsolatePlugin::new(isolate_cb));
@@ -81,7 +82,7 @@ impl FlutterWindow {
8182
engine.add_plugin(PlatformPlugin::new(platform_handler));
8283
engine.add_plugin(SettingsPlugin::default());
8384
engine.add_plugin(SystemPlugin::default());
84-
engine.add_plugin(TextInputPlugin::default());
85+
engine.add_plugin(TextInputPlugin::new(textinput_handler));
8586
engine.add_plugin(WindowPlugin::new(window_handler));
8687

8788
Ok(Self{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp