mirror of https://github.com/Wox-launcher/Wox
Fix #4080 add mouse support for results
This commit is contained in:
parent
fbd92202c2
commit
c30649cea2
|
@ -96,7 +96,12 @@ class WoxQueryResultView extends GetView<WoxLauncherController> {
|
|||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [Text("Actions", style: TextStyle(color: fromCssColor(controller.woxTheme.value.actionContainerHeaderFontColor), fontSize: 16.0)), const Divider(), getActionListView(), getActionQueryBox()],
|
||||
children: [
|
||||
Text("Actions", style: TextStyle(color: fromCssColor(controller.woxTheme.value.actionContainerHeaderFontColor), fontSize: 16.0)),
|
||||
const Divider(),
|
||||
getActionListView(),
|
||||
getActionQueryBox()
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
@ -138,7 +143,28 @@ class WoxQueryResultView extends GetView<WoxLauncherController> {
|
|||
itemExtent: WoxThemeUtil.instance.getResultListViewHeightByCount(1),
|
||||
itemBuilder: (context, index) {
|
||||
WoxQueryResult woxQueryResult = controller.getQueryResultByIndex(index);
|
||||
return WoxListItemView(
|
||||
return MouseRegion(
|
||||
onEnter: (_) {
|
||||
if (controller.isMouseMoved) {
|
||||
controller.setActiveResultIndex(index);
|
||||
}
|
||||
},
|
||||
onHover: (_) {
|
||||
if (!controller.isMouseMoved) {
|
||||
controller.isMouseMoved = true;
|
||||
controller.setActiveResultIndex(index);
|
||||
}
|
||||
},
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
// request focus to action query box since it will lose focus when tap
|
||||
controller.queryBoxFocusNode.requestFocus();
|
||||
},
|
||||
onDoubleTap: () {
|
||||
controller.onEnter(const UuidV4().generate());
|
||||
controller.queryBoxFocusNode.requestFocus();
|
||||
},
|
||||
child: WoxListItemView(
|
||||
key: controller.getResultItemGlobalKeyByIndex(index),
|
||||
woxTheme: controller.woxTheme.value,
|
||||
icon: woxQueryResult.icon,
|
||||
|
@ -148,6 +174,8 @@ class WoxQueryResultView extends GetView<WoxLauncherController> {
|
|||
isActive: controller.isResultActiveByIndex(index),
|
||||
listViewType: WoxListViewTypeEnum.WOX_LIST_VIEW_TYPE_RESULT.code,
|
||||
isGroup: woxQueryResult.isGroup,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
|
|
|
@ -96,6 +96,10 @@ class WoxLauncherController extends GetxController {
|
|||
Timer cleanToolbarTimer = Timer(const Duration(), () => {});
|
||||
final cleanToolbarDelay = 1000;
|
||||
|
||||
/// This flag is used to control whether the result item is selected by mouse hover.
|
||||
/// This is used to prevent the result item from being selected when the mouse is just hovering over the item in the result list.
|
||||
var isMouseMoved = false;
|
||||
|
||||
/// Triggered when received query results from the server.
|
||||
void onReceivedQueryResults(String traceId, List<WoxQueryResult> receivedResults) {
|
||||
if (receivedResults.isEmpty) {
|
||||
|
@ -338,6 +342,7 @@ class WoxLauncherController extends GetxController {
|
|||
|
||||
void onQueryBoxTextChanged(String value) {
|
||||
canArrowUpHistory = false;
|
||||
isMouseMoved = false;
|
||||
|
||||
if (currentQuery.value.queryType == WoxQueryTypeEnum.WOX_QUERY_TYPE_SELECTION.code) {
|
||||
// do local filter if query type is selection
|
||||
|
@ -742,6 +747,14 @@ class WoxLauncherController extends GetxController {
|
|||
return activeActionIndex.value == index;
|
||||
}
|
||||
|
||||
void setActiveResultIndex(int index) {
|
||||
activeResultIndex.value = index;
|
||||
currentPreview.value = results[index].preview;
|
||||
isShowPreviewPanel.value = currentPreview.value.previewData != "";
|
||||
resetActiveAction(const UuidV4().generate(), "mouse hover");
|
||||
results.refresh();
|
||||
}
|
||||
|
||||
/// update active actions based on active result and reset active action index to 0
|
||||
void resetActiveAction(String traceId, String reason) {
|
||||
var activeQueryResult = getActiveResult();
|
||||
|
|
Loading…
Reference in New Issue