text stringlengths 1 372 |
|---|
and positioned: |
context menu—Typically triggered by a right-click, |
a context menu is positioned close to the mouse, |
and is dismissed by clicking anywhere, |
selecting an option from the menu, or clicking outside it. |
Tooltip—Typically triggered by hovering for |
200-400ms over an interactive element, |
a tooltip is usually anchored to a widget |
(as opposed to the mouse position) and is dismissed |
when the mouse cursor leaves that widget. |
popup panel (also known as flyout)—Similar to a tooltip, |
a popup panel is usually anchored to a widget. |
the main difference is that panels are most often |
shown on a tap event, and they usually don’t hide |
themselves when the cursor leaves. |
instead, panels are typically dismissed by clicking |
outside the panel or by pressing a close or submit button. |
to show basic tooltips in flutter, |
use the built-in tooltip widget: |
<code_start> |
return const tooltip( |
message: 'i am a tooltip', |
child: Text('Hover over the text to show a tooltip.'), |
); |
<code_end> |
flutter also provides built-in context menus when editing |
or selecting text. |
to show more advanced tooltips, popup panels, |
or create custom context menus, |
you either use one of the available packages, |
or build it yourself using a stack or overlay. |
some available packages include: |
while these controls can be valuable for touch users as accelerators, |
they are essential for mouse users. these users expect |
to right-click things, edit content in place, |
and hover for more information. failing to meet those expectations |
can lead to disappointed users, or at least, |
a feeling that something isn’t quite right. |
<topic_end> |
<topic_start> |
horizontal button order |
on windows, when presenting a row of buttons, |
the confirmation button is placed at the start of |
the row (left side). on all other platforms, |
it’s the opposite. the confirmation button is |
placed at the end of the row (right side). |
this can be easily handled in flutter using the |
TextDirection property on row: |
<code_start> |
TextDirection btnDirection = |
DeviceType.isWindows ? TextDirection.rtl : TextDirection.ltr; |
return row( |
children: [ |
const spacer(), |
row( |
textDirection: btnDirection, |
children: [ |
DialogButton( |
label: 'cancel', |
onPressed: () => navigator.pop(context, false), |
), |
DialogButton( |
label: 'ok', |
onPressed: () => navigator.pop(context, true), |
), |
], |
), |
], |
); |
<code_end> |
<topic_end> |
<topic_start> |
menu bar |
another common pattern on desktop apps is the menu bar. |
on windows and linux, this menu lives as part of the chrome title bar, |
whereas on macOS, it’s located along the top of the primary screen. |
currently, you can specify custom menu bar entries using |
a prototype plugin, but it’s expected that this functionality will |
eventually be integrated into the main SDK. |
it’s worth mentioning that on windows and linux, |
you can’t combine a custom title bar with a menu bar. |
when you create a custom title bar, |
you’re replacing the native one completely, |
which means you also lose the integrated native menu bar. |
if you need both a custom title bar and a menu bar, |
you can achieve that by implementing it in flutter, |
similar to a custom context menu. |
<topic_end> |
<topic_start> |
drag and drop |
one of the core interactions for both touch-based and |
pointer-based inputs is drag and drop. although this |
interaction is expected for both types of input, |
there are important differences to think about when |
it comes to scrolling lists of draggable items. |
generally speaking, touch users expect to see drag handles |
to differentiate draggable areas from scrollable ones, |
or alternatively, to initiate a drag by using a long |
press gesture. this is because scrolling and dragging |
are both sharing a single finger for input. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.