首页 \ 问答 \ 查看 redhat 的版本号

查看 redhat 的版本号

查看 redhat 的版本号
更新时间:2024-01-19 22:01

最满意答案

看起来新焦点元素接收KeyUp事件。

我所做的是订阅KeyDown事件,检查Tab键并将事件标记为已处理。

protected override void OnAttached()
{
    var textBox = (TextBox)this.AssociatedObject;
    textBox.KeyDown += this.OnKeyDown;
    textBox.KeyUp += this.OnKeyUp;
    // don't forget to unsubscribe in OnDetached
}

private void OnKeyDown(object sender, KeyRoutedEventArgs e)
{
    if (e.Key == VirtualKey.Tab && !e.Handled)
    {
        e.Handled = this.Work(sender, e);
    }
}

private void OnKeyUp(object sender, KeyRoutedEventArgs e)
{
    if (e.Key != VirtualKey.Tab && !e.Handled)
    {
        e.Handled = this.Work(sender, e);
    }
}

这是进行聚焦工作的方法。 在我知道怎么做之前,代码在OnKeyUp

/// <returns>true if an action has been performed (focus next or execute command)</returns>
private bool Work(object sender, KeyRoutedEventArgs e)
{
    var isEnterKey = e.Key == VirtualKey.Enter;
    var isTabKey = e.Key == VirtualKey.Tab;

    if (/* there is something else to focus */)
    {
        // focus it
        return true;
    }

    return false;
}

Is looks like the newly focus element receives the KeyUp event.

What I did is subscribe to the KeyDown event, checked for the Tab key and marked the event as handled.

protected override void OnAttached()
{
    var textBox = (TextBox)this.AssociatedObject;
    textBox.KeyDown += this.OnKeyDown;
    textBox.KeyUp += this.OnKeyUp;
    // don't forget to unsubscribe in OnDetached
}

private void OnKeyDown(object sender, KeyRoutedEventArgs e)
{
    if (e.Key == VirtualKey.Tab && !e.Handled)
    {
        e.Handled = this.Work(sender, e);
    }
}

private void OnKeyUp(object sender, KeyRoutedEventArgs e)
{
    if (e.Key != VirtualKey.Tab && !e.Handled)
    {
        e.Handled = this.Work(sender, e);
    }
}

Here is the method that does the focusing work. The code was in OnKeyUp before I knew how to do.

/// <returns>true if an action has been performed (focus next or execute command)</returns>
private bool Work(object sender, KeyRoutedEventArgs e)
{
    var isEnterKey = e.Key == VirtualKey.Enter;
    var isTabKey = e.Key == VirtualKey.Tab;

    if (/* there is something else to focus */)
    {
        // focus it
        return true;
    }

    return false;
}

相关问答

更多
  • 我的预感是,当你按下tab键时,表单的输入会失去焦点,在键入之前发生。 尝试更改绑定到身体,如下所示: $('body').keyup(function(e) { console.log('keyup called'); var code = e.keyCode || e.which; if (code == '9') { alert('Tab pressed'); } }); 然后,如果这有效(它对我来说)尝试将绑定更改为keyDown,而是返回false。 ...
  • 看起来新焦点元素接收KeyUp事件。 我所做的是订阅KeyDown事件,检查Tab键并将事件标记为已处理。 protected override void OnAttached() { var textBox = (TextBox)this.AssociatedObject; textBox.KeyDown += this.OnKeyDown; textBox.KeyUp += this.OnKeyUp; // don't forget to unsubscribe in O ...
  • 编辑:由于你的元素是动态插入的,所以你必须像你的例子那样使用委托的on() ,但你应该把它绑定到keydown事件,因为@Marc注释,在IE中,keypress事件不捕获非字符键: $("#parentOfTextbox").on('keydown', '#textbox', function(e) { var keyCode = e.keyCode || e.which; if (keyCode == 9) { e.preventDefault(); // call c ...
  • 这是一个托管应用程序? WinRT应用程序作为进程外COM服务器运行。 您使用的大部分代码都是非托管的,例如您在XAML中使用的任何内容都是用C ++编写的。 但这是一个很难看到的实现细节,它已经被CLR内置的语言投影仔细包装。 这使得所有WinRT互操作看起来像托管类。 与您添加对COM组件的引用的方式不同,它看起来也像托管代码。 出于所有实际目的,您可以将您的应用程序称为托管应用程序,并且您将使用托管调试程序来修复错误。 它使用CLR还是100%原生? Native C ++是100%原生的。 如果您在 ...
  • 发生这种情况是因为使用MVVM和命令导航后 - UI线程被阻止。 并且,如果我使用调度程序进行导航,那么问题就解决了。 public void NavigateTo(object parameter) { if (_rootFrame != null) { CoreDispatcher dispatcher = CoreApplication.MainView.CoreWindow.Dispatcher; ...
  • 从Windows 8.1开始, Windows.UI.XAML.TextBox控件具有一个Paste事件处理程序,该事件处理程序在将内容插入控件之前触发。 如果将Handled属性设置为true ,则不会将文本插入TextBox 。 As of Windows 8.1, the Windows.UI.XAML.TextBox control has a Paste event handler which fires before the content is inserted into the contro ...
  • 我发现了一个名为PreviewKeyDown()的新事件 Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown If e.KeyCode = Keys.Tab Then Me.Text = "TAB Capture From TextBox1_KeyDown At " & Now.ToStr ...
  • 我会在这里回答,因为我无法在评论中添加图像。 正如我所建议的那样,看看模板。 在网格模板中(在网格和拆分模板中),RichTextColumns.cs应该提供一些灵感。 您可以看到RichEditBox控件的简单使用,或/和更多“高级”场景(多列)的组合。 RichEditBox位于XAML工具包中,适用于所有Windows STore应用程序,该列只是两个模板中的示例实现。 如果您只想要多行和滚动,只需使用RichEditBox控件即可。 将textwrapping设置为wrap,并将AcceptsRet ...
  • 诀窍是使用keydown并将字段的实际值与当前按下的字符组合起来,或者在keydown捕获TAB,并设置一个外部变量用于keyup如我的示例中所示。 编辑:事实上,我意识到不防止在keydown TAB的默认行为不会触发键盘。 所以,不需要变量,但只能防止keydown上的TAB。 无论如何,如果在某些情况下你所说的故障存在,这个版本总是有效的。 (function() { var tabKeyPressed = false; $("#t").keydown(function(e) { ...
  • 您看到此行为的原因是因为TextBox的内容在KeyDown事件发生后不久更新。 键入速度非常快时,可以按以下顺序执行此操作 KeyDown:T KeyUp:T KeyDown:E KeyDown:S KeyUp:E KeyUp:S 如果要处理在KeyUp事件中按下的最后一个键,则必须侦听KeyDown并将值存储在事件之间的某处。 我不会推荐这一点,因为你可以在许多订单中获得关键事件,你不会期望(特别是在非英语键盘上)。 我会坚持在KeyDown或KeyUp处理事件。 The reason you see ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。