Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from microsoft:master #56

Merged
merged 18 commits into from
Jun 11, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
V1 Calendar Accessibility: Added a way to leave focus when using Hard…
…ware Keyboard (microsoft#633)

* leave focus when tab pressed

* removing calendarView.kt changes

* removing unused import

---------

Co-authored-by: Anubhav Agrawal <anubagrawal@microsoft.com>
  • Loading branch information
Anubhvv and Anubhav Agrawal committed Apr 2, 2024
commit 570b2525fc428d9aa6bba330e44617065cc68aee
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
package com.microsoft.fluentuidemo.demos

import android.os.Bundle
import android.view.KeyEvent
import android.view.LayoutInflater
import android.view.View
import android.view.View.TEXT_ALIGNMENT_TEXT_START
import com.microsoft.fluentui.calendar.OnDateSelectedListener
import com.microsoft.fluentui.util.DateStringUtils
Expand Down Expand Up @@ -63,4 +65,22 @@ class CalendarViewActivity : DemoActivity() {
calenderBinding.exampleDateTitle.text = DateStringUtils.formatDateWithWeekDay(this, date)
calenderBinding.calendarView.setSelectedDateRange(date.toLocalDate(), Duration.ZERO, false)
}

/**
* This function allows the user to leave the calendar focus by pressing the tab key.
* @param keyCode The value in event.getKeyCode().
* @param event The KeyEvent object.
*/
override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean {
if (keyCode == KeyEvent.KEYCODE_TAB && calenderBinding.calendarView.hasFocus()) {
// Find the currently focused view
val focusedView = currentFocus
// Remove focus from the currently focused view
focusedView?.clearFocus()

return true // Consume the event
}
return super.onKeyDown(keyCode, event)
}

}