用于在 JQplot 中悬停/选择点的键盘事件
有没有办法将键盘事件绑定到jqPlot
?我试图仅使用左右箭头键将鼠标悬停在绘图上的点上。每个点也应该突出显示。
我知道有一些方法可以单击,双击等。
$('#chart1').bind('jqplotClick', function(ev, gridpos, datapos, neighbor) {
if (neighbor) {
}
});
我还实现了shift单击。
$('#chart1').bind('jqplotShiftClick', function(ev, gridpos, datapos, neighbor) {
if (neighbor) {
}
});
定义:
this.onClick = function(ev) {
// Event passed in is normalized and will have data attribute.
// Event passed out is unnormalized.
if (ev.shiftKey) {
var positions = getEventPosition(ev);
var p = ev.data.plot;
var neighbor = checkIntersection(positions.gridPos, p);
var evt = jQuery.Event('jqplotShiftClick');
evt.pageX = ev.pageX;
evt.pageY = ev.pageY;
$(this).trigger(evt, [positions.gridPos, positions.dataPos, neighbor, p]);
} else {
var positions = getEventPosition(ev);
var p = ev.data.plot;
var neighbor = checkIntersection(positions.gridPos, p);
var evt = jQuery.Event('jqplotClick');
evt.pageX = ev.pageX;
evt.pageY = ev.pageY;
$(this).trigger(evt, [positions.gridPos, positions.dataPos, neighbor, p]);
}
};
但在所有这些中,都涉及到点击。我希望能够在不实际选择点的情况下产生相同的效果。
如果您有任何想法,请告诉我。
Is there a way to bind keyboard events to jqPlot
? I am trying to hover through the points on a plot using only the left and right arrow keys. Also each point should highlight.
I know there are ways to click, double click etc.
$('#chart1').bind('jqplotClick', function(ev, gridpos, datapos, neighbor) {
if (neighbor) {
}
});
I have also implemented shift click.
$('#chart1').bind('jqplotShiftClick', function(ev, gridpos, datapos, neighbor) {
if (neighbor) {
}
});
definition:
this.onClick = function(ev) {
// Event passed in is normalized and will have data attribute.
// Event passed out is unnormalized.
if (ev.shiftKey) {
var positions = getEventPosition(ev);
var p = ev.data.plot;
var neighbor = checkIntersection(positions.gridPos, p);
var evt = jQuery.Event('jqplotShiftClick');
evt.pageX = ev.pageX;
evt.pageY = ev.pageY;
$(this).trigger(evt, [positions.gridPos, positions.dataPos, neighbor, p]);
} else {
var positions = getEventPosition(ev);
var p = ev.data.plot;
var neighbor = checkIntersection(positions.gridPos, p);
var evt = jQuery.Event('jqplotClick');
evt.pageX = ev.pageX;
evt.pageY = ev.pageY;
$(this).trigger(evt, [positions.gridPos, positions.dataPos, neighbor, p]);
}
};
But in all these, there is a click involved. I want to be able to produce the same effect without actually selecting the point.
Please let me know if you have any ideas.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我能想到的唯一方法是将
keydown
或keypress
事件附加/绑定到文档本身,并相应地对按键操作进行操作。这已合并到此处提供的示例中。
不要忘记在结果框架内单击以使用键盘.
The only way I can think of is to attach/bind the event of
keydown
orkeypress
to the document itself and act upon a key action accordingly.This was incorporated into the sample available here.
Do not forget to click inside the Result frame in order to use keyboard.