OnBackKeyPress未按预期工作(OnBackKeyPress is not working as expected)
在我的应用程序中,我有这两个功能。 自从我添加了
OnBackKeyPress
函数后,OnBackKeyPress
的if
语句即使我按下后退按钮也是如此(可能是因为e.cancel= true;
在OnBackKeyPress
)。protected override void OnNavigatedFrom(NavigationEventArgs e) { // On back navigation there is no need to save state. if (e.NavigationMode != System.Windows.Navigation.NavigationMode.Back) { StoreState(); //this should not run when i press back button } FilterPreviewPivot.SelectionChanged -= FilterPreviewPivot_SelectionChanged; base.OnNavigatedFrom(e); } protected override void OnBackKeyPress(CancelEventArgs e) { while (NavigationService.CanGoBack) NavigationService.RemoveBackEntry(); NavigationService.Navigate(new Uri("/Chooser.xaml", UriKind.Relative)); // cancel the navigation e.Cancel = true; }
In my app I have these two functions. Ever since I added the
OnBackKeyPress
function, theif
statement insideOnNavigatedFrom
is true even if I press back button (may be becausee.cancel= true;
insideOnBackKeyPress
).protected override void OnNavigatedFrom(NavigationEventArgs e) { // On back navigation there is no need to save state. if (e.NavigationMode != System.Windows.Navigation.NavigationMode.Back) { StoreState(); //this should not run when i press back button } FilterPreviewPivot.SelectionChanged -= FilterPreviewPivot_SelectionChanged; base.OnNavigatedFrom(e); } protected override void OnBackKeyPress(CancelEventArgs e) { while (NavigationService.CanGoBack) NavigationService.RemoveBackEntry(); NavigationService.Navigate(new Uri("/Chooser.xaml", UriKind.Relative)); // cancel the navigation e.Cancel = true; }
原文:https://stackoverflow.com/questions/21529128
更新时间:2023-05-21 18:05
最满意答案
我在这里回答了同样的问题: https : //github.com/paperjs/paper.js/issues/945
I have answered the same question here: https://github.com/paperjs/paper.js/issues/945
相关问答
更多-
Paper.js中的事件处理程序(Event handlers in Paper.js)[2024-01-15]
你可以使用attach()方法(或者它的jQuery风格的别名on())绑定多个事件处理程序。 您可以使用detach()或off()来删除它们。 以下是事件处理文档的一个修改示例: // Create a circle shaped path at the center of the view: var path = new Path.Circle({ center: view.center, radius: 25, fillColor: 'black' }); var shif ... -
我在这里回答了同样的问题: https : //github.com/paperjs/paper.js/issues/945 I have answered the same question here: https://github.com/paperjs/paper.js/issues/945
-
从0.2版开始,使用pure JavaScript中的paper.js很容易并且有很好的文档。 初始化的一种方法是: var scope = new paper.PaperScope(); scope.setup(myCanvas); 完整的文档在这里: http : //paper.js/tutorials/getting-started/using-javascript-directly/ 我不确定“没有画布”是什么意思,但paper.js确实需要画布对象来操作。 Since version 0.2, ...
-
这里有几个应该帮助你的vanilla Javascript解决方案: 解决方案1 检查按下哪个键码,以及如果shift键是使用本机事件对象关闭的。 function handleKeyDown(evt) { if (evt.which === 90 && evt.shiftKey) { // do a thing! } }; 解决方案2 保留一个全局变量来检测shift键是否关闭,并在你的keydown处理程序中使用它。 您还需要使用keyup事件处理程序重置它。 var ...
-
HTML5 canvas仍然是非常新鲜的环境。 你可以得到很多已经有的工具,但它们往往很不成熟。 我的答案只会涵盖部分问题,因为我只使用了KineticJS和EaselJS。 你可以从这个页面阅读意见开始(我的是底部的最后一个)。 不久之后,KineticJS的入门门槛较低。 它是简单的绘图库,也支持鼠标事件。 当我试图使用它时,它几乎无法扩展。 我发现很难根据我的需求进行定制。 EaselJS有点难以开始,但它也更先进。 现在它是其他libs的一部分,它们一起被称为CreateJS。 似乎很多发展都在那里 ...
-
我可以通过使用paperjs的早期版本来重新编制你的问题 - 特别是这个版本是jsfiddle上的版本。 我看到这些线偏移你用v 0.22的方式,然后用版本0.9.25正确渲染。 这是我的代码: