avm1: Drop focus on EditText when something else is clicked
In AVM1 text fields are somewhat special when handling focus. When a text field is clicked, it gains focus, when something else is clicked, it loses the focus. However, this logic only applies to text fields, other objects (buttons, movie clips) neither gain focus nor lose it upon press.
This commit is contained in:
parent
432dd0a37c
commit
516e10ae26
|
@ -1542,6 +1542,9 @@ impl Player {
|
|||
for (object, event) in events {
|
||||
let display_object = object.as_displayobject();
|
||||
if !display_object.avm1_removed() {
|
||||
if event == ClipEvent::Press {
|
||||
Self::update_focus_on_mouse_press(context, display_object);
|
||||
}
|
||||
object.handle_clip_event(context, event);
|
||||
if display_object.movie().is_action_script_3() {
|
||||
object.event_dispatch_to_avm2(context, event);
|
||||
|
@ -1575,6 +1578,23 @@ impl Player {
|
|||
needs_render
|
||||
}
|
||||
|
||||
fn update_focus_on_mouse_press(context: &mut UpdateContext, pressed_object: DisplayObject) {
|
||||
let is_avm2 = context.swf.is_action_script_3();
|
||||
|
||||
// Update AVM1 focus
|
||||
if !is_avm2 {
|
||||
let tracker = context.focus_tracker;
|
||||
// In AVM1 text fields are somewhat special when handling focus.
|
||||
// When a text field is clicked, it gains focus,
|
||||
// when something else is clicked, it loses the focus.
|
||||
// However, this logic only applies to text fields, other objects
|
||||
// (buttons, movie clips) neither gain focus nor lose it upon press.
|
||||
if tracker.get_as_edit_text().is_some() && pressed_object.as_edit_text().is_none() {
|
||||
tracker.set(None, context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Checks if two displayObjects have the same depth and id and accur in the same movie.s
|
||||
fn check_display_object_equality(object1: DisplayObject, object2: DisplayObject) -> bool {
|
||||
object1.depth() == object2.depth()
|
||||
|
|
Loading…
Reference in New Issue