home icon indicating copy to clipboard operation
home copied to clipboard

怎样将数字区输入设置为直接上屏

Open nlat opened this issue 1 year ago • 2 comments

我在选字的时候通常用主键区上部的数字进行选择,我希望将键盘右侧的数字区输入直接上屏。 不知道怎样实现,这个问题困惑了我很久,上网查询没有找到比较详细的教学,希望赐教,谢谢!

nlat avatar Mar 04 '24 09:03 nlat

需要編程實現。 現有程序對數字鍵盤的處理是用來選字。

lotem avatar Mar 04 '24 15:03 lotem

试了一下,可以用 lua 做,大致像下面这样:

-- commit_kbn.lua

local s = {}

function s.init( env )
    s.kb = { 'KP_0', 'KP_1', 'KP_2', 'KP_3', 'KP_4', 'KP_5', 'KP_6', 'KP_7', 'KP_8', 'KP_9' }
    for i, v in ipairs( s.kb ) do s.kb[v] = i - 1 end
end

function s.func( key, env )
    if key:release() or key:alt() or key:super() or key:ctrl() then return 2 end

    local context = env.engine.context
    local num = s.kb[key:repr()]
    if context:is_composing() and num then
        context:commit()
        context:commit_text( num )
        return 1
    end

    return 2
end
engine:
  processors:
    - lua_processor@*commit_kbn

非常感谢您提出的创意方案,我是一个 0 基础的小白,我学习学习怎样应用它,这对我来说很有帮助!再次感谢!

nlat avatar Mar 07 '24 00:03 nlat