

Ctrl+Fのショートカットキーで指定した場所に移動する機能を実装したのですが、表示内容を変更する機能のコンボボックスを押した後、このショートカットキーが反応しなくなる不具合が発生しています。本来はコンボボックスを押した後でもショートカットキーが反応するのが正常な動作です。

試したこととしては、ボタンのソースコードに下記のショートカットキーのソースコードを追加してみたのですが、改善しませんでした。この場合、コンボボックスのソースコードにショートカットキーの処理を追記すればよろしいでしょうか。ご助言の程お願いします。

[code]

    // Ctrl+Fで検索ウィンドウを開く
        property bool is_key_control: false
        property bool is_key_f: false
        Item {
            anchors.fill: parent
            focus: true
            Keys.onPressed: (event)=> {
                if (event.key === Qt.Key_Control) {
                    is_key_control = true
                    event.accepted = true;
                }
                else if (event.key === Qt.Key_F) {
                    is_key_f = true
                    event.accepted = true;
                }
            }
            Keys.onReleased: (event)=> {
                if (event.key === Qt.Key_Control) {
                    is_key_control = false
                    event.accepted = true;
                }
                else if (event.key === Qt.Key_F) {
                    is_key_f = false
                    event.accepted = true;
                }
                else {
                    // 何もしない
                    return;
                }
    
                if (((is_key_control == true) && (is_key_f == false)) ||
                    ((is_key_control == false) && (is_key_f == true))) {
                    if (symbol_search_window.visible === false){
                        symbol_search_window.visible = true
                        symbol_search_window.x=symbol_search_button.x + 50 //座標リセット
                        symbol_search_window.y=symbol_search_button.y + 100
    
                        is_key_control = false
                        is_key_f = false
    
                        //コンボボックスの更新
                        dispManager.ReadSymbolSearchFile()
                        dispManager.UpdateSymbolKind()
                        dispManager.UpdateSymbolName(symbol_kind_combo.textAt(0))
                    }
                }
            }
        }
    
[/code]

ボタンのソースコードは下記の通りです。

[code]

    ComboBox{
            id:viewmode
            x:80
            y:5
            height:35
            width:125
            currentIndex:0
    
            //表示モード選択ボックス(コンボボックス)の見た目変更
            background: Rectangle{
                color:Color.combobox
                border.color: Color.combobox_border
            }
            //リストの見た目
            delegate: ItemDelegate{
                id:combobox_style
                width:viewmode.width - 2
                height:20
                padding:0
                contentItem:Text{
                    color:hovered? Color.combobox_list_text_hover : Color.combobox_list_text　//マウスカーソルを合わせたときに色を変える
                    text:modelData
                    verticalAlignment: Text.AlignVCenter
                    horizontalAlignment: Text.AlignLeft
                    leftPadding: 20
                }
                background: Rectangle{
                    color:hovered? Color.combobox_list_hover : Color.combobox_list　//マウスカーソルを合わせたときに色を変える
                    anchors.left:combobox_style.left
                    anchors.leftMargin:  1
                    width:combobox_style.width
                    height:combobox_style.height
                }
            }
    
            //combobox右端の逆三角形を描画
            indicator:Canvas{
                id:canvas
                x:viewmode.width - width - viewmode.rightPadding
                y:viewmode.topPadding + (viewmode.availableHeight - height) / 2
                width: 12
                height: 8
                contextType: "2d"
    
                Connections{
                    target:viewmode
                    function onPressedChanged(){canvas.requestPaint();}
                }
                onPaint:{
                    context.reset();
                    context.moveTo(0,0);
                    context.lineTo(width, 0);
                    context.lineTo(width / 2, height);
                    context.closePath();
                    context.fillStyle = viewmode.pressed ? Color.combobox_canvas_pressed:Color.combobox_canvas;
                    context.fill();
                }
            }
    
            //comboboxのテキストを調整
            contentItem: Text{
                leftPadding: 5
                text:viewmode.displayText
                verticalAlignment: Text.AlignVCenter
                elide:Text.ElideRight
            }
    
            model:ListModel{
                property bool completed: false
                Component.onCompleted: {
                    append({text:Text_Js.viewmode_list1[Text_Js.language_no]})
                    append({text:Text_Js.viewmode_list2[Text_Js.language_no]})
                    append({text:Text_Js.viewmode_list3[Text_Js.language_no]})
                    append({text:Text_Js.viewmode_list4[Text_Js.language_no]})
                    append({text:Text_Js.viewmode_list5[Text_Js.language_no]})
                    append({text:Text_Js.viewmode_list6[Text_Js.language_no]})
                }
            }
            onActivated: {
                if(viewmode.currentIndex === 0){ //Line OverView
                    window.segment_visible = true
                    window.segment_add001_visible = true
                    window.segment_add002_visible = false
                    window.tc_visible = false
                    window.tc_add002_visible = false
                    window.tc_add003_visible = false
                    window.signal_visible = false
                    window.signal_add001_visible = false
                    window.sw_visible = false
                    window.sw_add002_visible = false
                    window.trainStop_visible = false
                    window.trainStop_add001_visible = false
                    window.virtualSignal_visible = false
                    window.virtualSignal_add001_visible = false
                    window.virtualBlock_visible = false
                    window.virtualBlock_add001_visible = false
                    window.awsTS_visible = false
                    window.awsTS_add001_visible = false
                    window.cbtcTS_visible = false
                    window.cbtcTS_add001_visible = false
                    window.rlTS_visible = false
                    window.rlTS_add001_visible = false
                    window.transponder_visible = false
                    window.transponder_add001_visible = false
                    window.cTransponder_visible = false
                    window.cTransponder_add001_visible = false
                    window.bumper_visible = false
                    window.bumper_add001_visible = false
                    window.dangerousPoint_visible = false
                    window.sieve_visible = false
                    window.sieve_add001_visible = false
                    window.platform_visible = true
                    window.platform_add001_visible = true
                    window.platform_add002_visible = false
                    window.stoppingPoint_visible = false
                    window.stoppingPoint_add001_visible = false
                    window.stoppingPoint_add002_visible = false
                    window.pStoppingPoint_visible = false
                    window.pStoppingPoint_add001_visible = false
                    window.radioAntenna_visible = false
                    window.radioAntenna_add001_visible = false
                    window.radioCellLimit_visible = false
                    window.radioCellLimit_add002_visible = false
                    window.zcTerritory_visible = false
                    window.zcTerritory_add002_visible = false
                    window.cbtcTerritory_visible = false
                    window.cbtcTerritory_add002_visible = false
                    window.update_view = false //表示変化なし
                    window.train_view = false //列車表示なし
                    window.symbol_visible = false
                }else if(viewmode.currentIndex === 1){ //Line Detail1
                    window.segment_visible = true
                    window.segment_add001_visible = true
                    window.segment_add002_visible = false
                    window.tc_visible = true
                    window.tc_add002_visible = false
                    window.tc_add003_visible = false
                    window.signal_visible = true
                    window.signal_add001_visible = false
                    window.sw_visible = true
                    window.sw_add002_visible = false
                    window.trainStop_visible = true
                    window.trainStop_add001_visible = false
                    window.virtualSignal_visible = true
                    window.virtualSignal_add001_visible = false
                    window.virtualBlock_visible = true
                    window.virtualBlock_add001_visible = false
                    window.awsTS_visible = true
                    window.awsTS_add001_visible = false
                    window.cbtcTS_visible = true
                    window.cbtcTS_add001_visible = false
                    window.rlTS_visible = true
                    window.rlTS_add001_visible = false
                    window.transponder_visible = false
                    window.transponder_add001_visible = false
                    window.cTransponder_visible = false
                    window.cTransponder_add001_visible = false
                    window.bumper_visible = false
                    window.bumper_add001_visible = false
                    window.dangerousPoint_visible = false
                    window.sieve_visible = false
                    window.sieve_add001_visible = false
                    window.platform_visible = false
                    window.platform_add001_visible = false
                    window.platform_add002_visible = false
                    window.stoppingPoint_visible = false
                    window.stoppingPoint_add001_visible = false
                    window.stoppingPoint_add002_visible = false
                    window.pStoppingPoint_visible = false
                    window.pStoppingPoint_add001_visible = false
                    window.radioAntenna_visible = false
                    window.radioAntenna_add001_visible = false
                    window.radioCellLimit_visible = false
                    window.radioCellLimit_add002_visible = false
                    window.zcTerritory_visible = false
                    window.zcTerritory_add002_visible = false
                    window.cbtcTerritory_visible = false
                    window.cbtcTerritory_add002_visible = false
                    window.update_view = true //表示変化あり
                    window.train_view = true //列車表示あり
                    window.symbol_visible = false
                }else if(viewmode.currentIndex === 2){ //Line Detail2
                    window.segment_visible = true
                    window.segment_add001_visible = true
                    window.segment_add002_visible = true
                    window.tc_visible = true
                    window.tc_add002_visible = true
                    window.tc_add003_visible = true
                    window.signal_visible = true
                    window.signal_add001_visible = true
                    window.sw_visible = true
                    window.sw_add002_visible = true
                    window.trainStop_visible = true
                    window.trainStop_add001_visible = true
                    window.virtualSignal_visible = true
                    window.virtualSignal_add001_visible = true
                    window.virtualBlock_visible = true
                    window.virtualBlock_add001_visible = true
                    window.awsTS_visible = true
                    window.awsTS_add001_visible = true
                    window.cbtcTS_visible = true
                    window.cbtcTS_add001_visible = true
                    window.rlTS_visible = true
                    window.rlTS_add001_visible = true
                    window.transponder_visible = false
                    window.transponder_add001_visible = false
                    window.cTransponder_visible = false
                    window.cTransponder_add001_visible = false
                    window.bumper_visible = false
                    window.bumper_add001_visible = false
                    window.dangerousPoint_visible = false
                    window.sieve_visible = false
                    window.sieve_add001_visible = false
                    window.platform_visible = false
                    window.platform_add001_visible = false
                    window.platform_add002_visible = false
                    window.stoppingPoint_visible = false
                    window.stoppingPoint_add001_visible = false
                    window.stoppingPoint_add002_visible = false
                    window.pStoppingPoint_visible = false
                    window.pStoppingPoint_add001_visible = false
                    window.radioAntenna_visible = false
                    window.radioAntenna_add001_visible = false
                    window.radioCellLimit_visible = false
                    window.radioCellLimit_add002_visible = false
                    window.zcTerritory_visible = false
                    window.zcTerritory_add002_visible = false
                    window.cbtcTerritory_visible = false
                    window.cbtcTerritory_add002_visible = false
                    window.update_view = true //表示変化あり
                    window.train_view = false //列車表示なし
                    window.symbol_visible = true
                }else if(viewmode.currentIndex === 3){ //Line Detail3
                    window.segment_visible = true
                    window.segment_add001_visible = true
                    window.segment_add002_visible = false
                    window.tc_visible = true
                    window.tc_add002_visible = false
                    window.tc_add003_visible = false
                    window.signal_visible = true
                    window.signal_add001_visible = false
                    window.sw_visible = true
                    window.sw_add002_visible = false
                    window.trainStop_visible = true
                    window.trainStop_add001_visible = false
                    window.virtualSignal_visible = true
                    window.virtualSignal_add001_visible = false
                    window.virtualBlock_visible = true
                    window.virtualBlock_add001_visible = false
                    window.awsTS_visible = true
                    window.awsTS_add001_visible = false
                    window.cbtcTS_visible = true
                    window.cbtcTS_add001_visible = false
                    window.rlTS_visible = true
                    window.rlTS_add001_visible = false
                    window.transponder_visible = true
                    window.transponder_add001_visible = false
                    window.cTransponder_visible = true
                    window.cTransponder_add001_visible = false
                    window.bumper_visible = true
                    window.bumper_add001_visible = false
                    window.dangerousPoint_visible = true
                    window.sieve_visible = true
                    window.sieve_add001_visible = false
                    window.platform_visible = true
                    window.platform_add001_visible = false
                    window.platform_add002_visible = false
                    window.stoppingPoint_visible = true
                    window.stoppingPoint_add001_visible = false
                    window.stoppingPoint_add002_visible = false
                    window.pStoppingPoint_visible = true
                    window.pStoppingPoint_add001_visible = false
                    window.radioAntenna_visible = true
                    window.radioAntenna_add001_visible = false
                    window.radioCellLimit_visible = true
                    window.radioCellLimit_add002_visible = false
                    window.zcTerritory_visible = true
                    window.zcTerritory_add002_visible = false
                    window.cbtcTerritory_visible = true
                    window.cbtcTerritory_add002_visible = false
                    window.update_view = true //表示変化あり
                    window.train_view = true //列車表示あり
                    window.symbol_visible = true
                }else if(viewmode.currentIndex === 4){ //Line Detail4
                    window.segment_visible = true
                    window.segment_add001_visible = true
                    window.segment_add002_visible = true
                    window.tc_visible = true
                    window.tc_add002_visible = true
                    window.tc_add003_visible = true
                    window.signal_visible = true
                    window.signal_add001_visible = true
                    window.sw_visible = true
                    window.sw_add002_visible = true
                    window.trainStop_visible = true
                    window.trainStop_add001_visible = true
                    window.virtualSignal_visible = true
                    window.virtualSignal_add001_visible = true
                    window.virtualBlock_visible = true
                    window.virtualBlock_add001_visible = true
                    window.awsTS_visible = true
                    window.awsTS_add001_visible = true
                    window.cbtcTS_visible = true
                    window.cbtcTS_add001_visible = true
                    window.rlTS_visible = true
                    window.rlTS_add001_visible = true
                    window.transponder_visible = true
                    window.transponder_add001_visible = true
                    window.cTransponder_visible = true
                    window.cTransponder_add001_visible = true
                    window.bumper_visible = true
                    window.bumper_add001_visible = true
                    window.dangerousPoint_visible = true
                    window.sieve_visible = true
                    window.sieve_add001_visible = true
                    window.platform_visible = true
                    window.platform_add001_visible = true
                    window.platform_add002_visible = true
                    window.stoppingPoint_visible = true
                    window.stoppingPoint_add001_visible = true
                    window.stoppingPoint_add002_visible = true
                    window.pStoppingPoint_visible = true
                    window.pStoppingPoint_add001_visible = true
                    window.radioAntenna_visible = true
                    window.radioAntenna_add001_visible = true
                    window.radioCellLimit_visible = true
                    window.radioCellLimit_add002_visible = true
                    window.zcTerritory_visible = true
                    window.zcTerritory_add002_visible = true
                    window.cbtcTerritory_visible = true
                    window.cbtcTerritory_add002_visible = true
                    window.update_view = true //表示変化あり
                    window.train_view = false //列車表示なし
                    window.symbol_visible = true
                }else if(viewmode.currentIndex === 5){ //手動
                    window.update_view = true //表示変化あり
                    window.train_view = true //表示変化なし
                }
            }
    
        }
        //Mode文字列表示
        Text{
            id:mode_text
            font.pointSize: 12
            width: 60
            height: 35
            anchors.right:viewmode.left
            anchors.rightMargin: 10
            anchors.top:viewmode.top
            verticalAlignment: Text.AlignVCenter
            horizontalAlignment: Text.AlignHCenter
            text:Text_Js.mode[Text_Js.language_no]
        }
    
        //コンボボックスとその他のボタンを仕切る
        ToolSeparator{
            id: separator2
            height: 40
            anchors.left:viewmode.right
            anchors.rightMargin: 5
            anchors.top:parent.top
            anchors.topMargin: 2
        }
    
[/code]


CC BY-SA 4.0
2023-02-21T02:17:03.350
93934
2023-03-06T04:22:12.787
2023-03-06T04:22:12.787
47970
47970
question
qt
ある箇所をクリックするとショートカットキーが反応しなくなる