Я испытываю проблему с записью внутри нативного Android horizontalscrollview, который я интегрировал с использованием картирования обработчиков в приложении Maui. экран), запись неожиданно получает фокус.
public partial class MainPage : ContentPage
{
Entry mauiEntry;
public MainPage()
{
InitializeComponent();
// Initialize the Entry
mauiEntry = new Entry
{
Placeholder = "Type here",
BackgroundColor = Colors.LightGray,
TextColor = Colors.Black,
HeightRequest = 40,
WidthRequest = 200
};
// Create the innermost view that will contain the Entry
var innerView = new ContentView
{
Content = mauiEntry,
BackgroundColor = Colors.Beige,
Padding = new Thickness(10)
};
// Create the middle view that contains the inner view
var middleView = new ContentView
{
Content = innerView,
BackgroundColor = Colors.Yellow,
WidthRequest = 300,
HeightRequest = 500,
Padding = new Thickness(20)
};
// Create the top-level grid that contains the middle view
var container = new Grid
{
WidthRequest = 350,
HeightRequest = 550,
BackgroundColor = Colors.Violet
};
// Add the middle view to the grid
container.Children.Add(middleView);
var horizontalScrollWrapper = new InteractiveScrollViewExt(container)
{
BackgroundColor = Colors.LightPink
};
myGrid.Children.Add(horizontalScrollWrapper);
}
private void Unfocu_Clicked(object sender, EventArgs e)
{
mauiEntry.Unfocus();
}
}
public class InteractiveScrollViewExt : View
{
public View Content { get; }
public InteractiveScrollViewExt(View child) => Content = child;
}
public class InteractiveScrollViewExtHandler : ViewHandler
{
public InteractiveScrollViewExtHandler() : base(ViewHandler.ViewMapper)
{
}
protected override HorizontalScrollViewer CreatePlatformView()
{
var context = MauiApplication.Current.ApplicationContext!;
var scrollView = new HorizontalScrollViewer(context);
if (VirtualView.Content is not null)
{
var viewHandler = VirtualView.Content.ToHandler(MauiContext!);
var platformView = viewHandler.PlatformView as Android.Views.View;
scrollView.AddView(platformView);
}
return scrollView;
}
}
public class HorizontalScrollViewer : HorizontalScrollView
{
public HorizontalScrollViewer(Context? context) : base(context)
{
this.ClipToOutline = true;
}
}
`
Почему вход приобретает фокусировку при прохождении в любом месте внутри Horizontalscrollview ? ожидаемое поведение:
inpit должна получить фокус только при напряжении. Свигарование или постукивание в других местах в горизонтальскриллхвел не должно влиять на его состояние фокуса.
Я испытываю проблему с записью внутри нативного Android horizontalscrollview, который я интегрировал с использованием картирования обработчиков в приложении Maui. экран), запись неожиданно получает фокус.[code]public partial class MainPage : ContentPage { Entry mauiEntry; public MainPage() { InitializeComponent();
// Create the innermost view that will contain the Entry var innerView = new ContentView { Content = mauiEntry, BackgroundColor = Colors.Beige, Padding = new Thickness(10) };
// Create the middle view that contains the inner view var middleView = new ContentView { Content = innerView, BackgroundColor = Colors.Yellow, WidthRequest = 300, HeightRequest = 500, Padding = new Thickness(20) };
// Create the top-level grid that contains the middle view var container = new Grid { WidthRequest = 350, HeightRequest = 550, BackgroundColor = Colors.Violet };
// Add the middle view to the grid container.Children.Add(middleView);
var horizontalScrollWrapper = new InteractiveScrollViewExt(container) { BackgroundColor = Colors.LightPink };
public class InteractiveScrollViewExt : View { public View Content { get; } public InteractiveScrollViewExt(View child) => Content = child; }
public class InteractiveScrollViewExtHandler : ViewHandler { public InteractiveScrollViewExtHandler() : base(ViewHandler.ViewMapper) { }
protected override HorizontalScrollViewer CreatePlatformView() { var context = MauiApplication.Current.ApplicationContext!; var scrollView = new HorizontalScrollViewer(context); if (VirtualView.Content is not null) { var viewHandler = VirtualView.Content.ToHandler(MauiContext!); var platformView = viewHandler.PlatformView as Android.Views.View; scrollView.AddView(platformView); } return scrollView; } }
public class HorizontalScrollViewer : HorizontalScrollView { public HorizontalScrollViewer(Context? context) : base(context) { this.ClipToOutline = true; } } [/code] ` Почему вход приобретает фокусировку при прохождении в любом месте внутри Horizontalscrollview ? [b] ожидаемое поведение: [/b]
inpit должна получить фокус только при напряжении. Свигарование или постукивание в других местах в горизонтальскриллхвел не должно влиять на его состояние фокуса.