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(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
crossAxisAlignment: CrossAxisAlignment.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,16 +143,39 @@ class WoxQueryResultView extends GetView<WoxLauncherController> {
|
||||||
itemExtent: WoxThemeUtil.instance.getResultListViewHeightByCount(1),
|
itemExtent: WoxThemeUtil.instance.getResultListViewHeightByCount(1),
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
WoxQueryResult woxQueryResult = controller.getQueryResultByIndex(index);
|
WoxQueryResult woxQueryResult = controller.getQueryResultByIndex(index);
|
||||||
return WoxListItemView(
|
return MouseRegion(
|
||||||
key: controller.getResultItemGlobalKeyByIndex(index),
|
onEnter: (_) {
|
||||||
woxTheme: controller.woxTheme.value,
|
if (controller.isMouseMoved) {
|
||||||
icon: woxQueryResult.icon,
|
controller.setActiveResultIndex(index);
|
||||||
title: woxQueryResult.title,
|
}
|
||||||
tails: woxQueryResult.tails,
|
},
|
||||||
subTitle: woxQueryResult.subTitle,
|
onHover: (_) {
|
||||||
isActive: controller.isResultActiveByIndex(index),
|
if (!controller.isMouseMoved) {
|
||||||
listViewType: WoxListViewTypeEnum.WOX_LIST_VIEW_TYPE_RESULT.code,
|
controller.isMouseMoved = true;
|
||||||
isGroup: woxQueryResult.isGroup,
|
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,
|
||||||
|
title: woxQueryResult.title,
|
||||||
|
tails: woxQueryResult.tails,
|
||||||
|
subTitle: woxQueryResult.subTitle,
|
||||||
|
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(), () => {});
|
Timer cleanToolbarTimer = Timer(const Duration(), () => {});
|
||||||
final cleanToolbarDelay = 1000;
|
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.
|
/// Triggered when received query results from the server.
|
||||||
void onReceivedQueryResults(String traceId, List<WoxQueryResult> receivedResults) {
|
void onReceivedQueryResults(String traceId, List<WoxQueryResult> receivedResults) {
|
||||||
if (receivedResults.isEmpty) {
|
if (receivedResults.isEmpty) {
|
||||||
|
@ -338,6 +342,7 @@ class WoxLauncherController extends GetxController {
|
||||||
|
|
||||||
void onQueryBoxTextChanged(String value) {
|
void onQueryBoxTextChanged(String value) {
|
||||||
canArrowUpHistory = false;
|
canArrowUpHistory = false;
|
||||||
|
isMouseMoved = false;
|
||||||
|
|
||||||
if (currentQuery.value.queryType == WoxQueryTypeEnum.WOX_QUERY_TYPE_SELECTION.code) {
|
if (currentQuery.value.queryType == WoxQueryTypeEnum.WOX_QUERY_TYPE_SELECTION.code) {
|
||||||
// do local filter if query type is selection
|
// do local filter if query type is selection
|
||||||
|
@ -742,6 +747,14 @@ class WoxLauncherController extends GetxController {
|
||||||
return activeActionIndex.value == index;
|
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
|
/// update active actions based on active result and reset active action index to 0
|
||||||
void resetActiveAction(String traceId, String reason) {
|
void resetActiveAction(String traceId, String reason) {
|
||||||
var activeQueryResult = getActiveResult();
|
var activeQueryResult = getActiveResult();
|
||||||
|
|
Loading…
Reference in New Issue