mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-09-26 00:40:13 +00:00
fix: menu displayed at mouse location
This commit is contained in:
parent
c8d5769b11
commit
ab4a2e8b07
@ -76,13 +76,7 @@ class ViewDisclosureRegion extends StatelessWidget
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Listener(
|
return Listener(
|
||||||
onPointerDown: (event) => {
|
onPointerDown: (event) => {_handleClick(event, context)},
|
||||||
if (event.kind == PointerDeviceKind.mouse &&
|
|
||||||
event.buttons == kSecondaryMouseButton)
|
|
||||||
{
|
|
||||||
show(context),
|
|
||||||
}
|
|
||||||
},
|
|
||||||
child: child,
|
child: child,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -101,6 +95,17 @@ class ViewDisclosureRegion extends StatelessWidget
|
|||||||
(wrapper) => onSelected(dartz.some(wrapper.inner)),
|
(wrapper) => onSelected(dartz.some(wrapper.inner)),
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void _handleClick(PointerDownEvent event, BuildContext context) {
|
||||||
|
if (event.kind == PointerDeviceKind.mouse &&
|
||||||
|
event.buttons == kSecondaryMouseButton) {
|
||||||
|
RenderBox box = context.findRenderObject() as RenderBox;
|
||||||
|
Offset position = box.localToGlobal(Offset.zero);
|
||||||
|
double x = event.position.dx - position.dx - box.size.width;
|
||||||
|
double y = event.position.dy - position.dy - box.size.height;
|
||||||
|
show(context, anchorOffset: Offset(x, y));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ViewDisclosureActionWrapper extends ActionItem {
|
class ViewDisclosureActionWrapper extends ActionItem {
|
||||||
|
@ -86,7 +86,6 @@ class ViewSectionItem extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return ViewDisclosureRegion(
|
return ViewDisclosureRegion(
|
||||||
// context.read<ViewBloc>().add(const ViewEvent.setIsEditing(true)),
|
|
||||||
onSelected: (action) {
|
onSelected: (action) {
|
||||||
context.read<ViewBloc>().add(const ViewEvent.setIsEditing(false));
|
context.read<ViewBloc>().add(const ViewEvent.setIsEditing(false));
|
||||||
_handleAction(context, action);
|
_handleAction(context, action);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user