HotKey icon indicating copy to clipboard operation
HotKey copied to clipboard

HotKey is blocking onKeyPress

Open mjasonlouw opened this issue 1 year ago • 0 comments

I use HotKey in my AppDelegate class but now when im trying to use onKeyPress in my view it no longer works. Is there no way to get them to work together?

delegate logic:

  let hotKey = HotKey(key: .c, modifiers: [.command, .option])
    
    hotKey.keyDownHandler = {
        guard let window = self.window else { return  }
        if self.hide {
            self.hide.toggle()
            window.orderOut(nil)
      
        } else {
            self.hide.toggle()
            window.orderFront(nil)
        }
    }
    
    self.hotKey = hotKey
    

View Logic:

 GroupBox{
          VStack(alignment: .leading) {
              CopyCard(copy: clipboardMonitor.copies[index])
          }
      }
      .id(index)
      .frame(maxWidth: .infinity)
      .listRowSeparator(.hidden)
      .focusable()
      .focused($selectedIndex, equals: index)
      .onKeyPress(.downArrow) {
          selectedIndex = index + 1
          stateIndex = selectedIndex ?? 0
          print("down")
          return .handled
      }

mjasonlouw avatar Dec 30 '24 18:12 mjasonlouw