Skip to content

HotKey is blocking onKeyPress #50

Description

@mjasonlouw

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
      }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions