Skip to content

Conversation

@nathan-ed
Copy link

Disclaimer

Everything was implemented using Claude Code Web and verified by the user.

Summary

Added autocomplete dropdown and insert comment when hitting ENTER to the T view (text comments) and PDF navigation improvements with left/right arrows.

Autocomplete Dropdown for Text Comments

  • Display matching remarks from favorites/lasts/onFile sections as user types
  • Navigate dropdown with UP/DOWN arrow keys
  • Insert selected remark with ENTER key or mouse click
  • ESC key removes focus from text area to enable app-level navigation
  • Preserves full text formatting (font, size, color, bold, italic)
  • Maintains existing left panel highlighting behavior

Technical implementation:

  • Custom ListView cell factory with Label graphics for proper rendering
  • Dual event filters (KEY_PRESSED and KEY_TYPED) to handle Enter key
  • Dynamic text color based on selection state (white when selected, black otherwise)
  • Popup with autoHide behavior positioned below text area
  • List height: 250px preferred, 400px max for full visibility

LEFT/RIGHT Arrow Navigation Between PDFs

  • LEFT arrow: Navigate to previous PDF in list
  • RIGHT arrow: Navigate to next PDF in list
  • Preserves page number across PDFs (scrolls to top of same page in next PDF)
  • Uses lazy keyboard shortcuts (lower priority, safe UI elements only)

Technical implementation:

  • Added forceScrollToPage field to MainScreen for page targeting
  • Pass resetScrollValue=true to openFile() to prevent Edition scroll restoration
  • 500ms delay ensures layout operations (showPages, loadEdition, updatePaneDimensions) complete
  • Uses scrollToPage() method for reliable scroll positioning

Known limitation: Page preservation only works reliably when at the top of a page. When scrolled within a page, navigation may jump to the next page due to viewport detection behavior of getFirstTopVisiblePage().

Files modified:

  • TextTab.java: Autocomplete dropdown functionality
  • KeyboardShortcuts.java: LEFT/RIGHT arrow handlers for PDF navigation
  • FileTab.java: loadPreviousFilePreservePage() and loadNextFilePreservePage()
  • MainScreen.java: Page targeting system with forceScrollToPage

## Autocomplete Dropdown for Text Comments
- Display matching remarks from favorites/lasts/onFile sections as user types
- Navigate dropdown with UP/DOWN arrow keys
- Insert selected remark with ENTER key or mouse click
- ESC key removes focus from text area to enable app-level navigation
- Preserves full text formatting (font, size, color, bold, italic)
- Maintains existing left panel highlighting behavior

Technical implementation:
- Custom ListView cell factory with Label graphics for proper rendering
- Dual event filters (KEY_PRESSED and KEY_TYPED) to handle Enter key
- Dynamic text color based on selection state (white when selected, black otherwise)
- Popup with autoHide behavior positioned below text area
- List height: 250px preferred, 400px max for full visibility

## LEFT/RIGHT Arrow Navigation Between PDFs
- LEFT arrow: Navigate to previous PDF in list
- RIGHT arrow: Navigate to next PDF in list
- Preserves page number across PDFs (scrolls to top of same page in next PDF)
- Uses lazy keyboard shortcuts (lower priority, safe UI elements only)

Technical implementation:
- Added forceScrollToPage field to MainScreen for page targeting
- Pass resetScrollValue=true to openFile() to prevent Edition scroll restoration
- 500ms delay ensures layout operations (showPages, loadEdition, updatePaneDimensions) complete
- Uses scrollToPage() method for reliable scroll positioning

Known limitation: Page preservation only works reliably when at the top of a page.
When scrolled within a page, navigation may jump to the next page due to viewport
detection behavior of getFirstTopVisiblePage().

Files modified:
- TextTab.java: Autocomplete dropdown functionality
- KeyboardShortcuts.java: LEFT/RIGHT arrow handlers for PDF navigation
- FileTab.java: loadPreviousFilePreservePage() and loadNextFilePreservePage()
- MainScreen.java: Page targeting system with forceScrollToPage
@ClementGre
Copy link
Owner

Thank you for contributing to PDF4Teachers. Here is a review of your MR :

  • There was already a mechanism to insert matching remarks from favorites/lasts/onFile sections as user types, and navigating with UP/DOWN arrow keys. It is not a dropdown, but a highlight of matching elements in the list, navigable with arrows. The dropdown you developed is then a redundant feature that allows the user to see more easily the matching elements, but that goes over the other elements of the sidebar, possibly reducing the user experience. What do you think about it? Also, would there be a way to use a ListView from JMetro for not having to customize the theme manually?
  • About the navigation between PDFs:
    • You edited the LEFT/RIGHT shortcut, but not the SHORTCUT_DOWN + ALT_DOWN + LEFT/RIGHT. Is this a choice, why ? I think it is interesting to use two different shortcuts for different behaviors, but it can be a lot for users, and it might be better to use the shortcut with SHORTCUT_DOWN + ALT_DOWN for this feature. We should also add AutoToolTips (see AutoTipsManager.java) and edit the documentation (I can do this myself later).
    • To fix your "Known limitation": you could remove the page number indirection and work only with the scroll value (0-1), or the y shift position. Anyway, a teacher using this feature will use it only on documents of the same size (hence the scroll value), or at least on documents of same page size (hence the y shift position).
    • About "Uses scrollToPage()" : can you instead use scrollByTranslateY disabling the animation, or even updatePaneDimensions if using scroll value ? This should allow you to remove the 500ms delay, removing the scrolling animation on switching to the next document.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants