Skip to content

Add Calendar using QCalendarWidget #372

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

Merged
merged 1 commit into from
Jul 7, 2022

Conversation

private-yusuke
Copy link
Contributor

This PR adds Calendar, a component inheriting QCalendarWidget.

Example

import {
  DateFormat,
  DayOfWeek,
  NativeElement,
  QCalendarWidgetSignals,
  QDate,
} from "@nodegui/nodegui";
import {
  Calendar,
  Renderer,
  useEventHandler,
  Window,
} from "@nodegui/react-nodegui";
import React from "react";
const App = () => {
  const calendarClickHandler = useEventHandler<QCalendarWidgetSignals>(
    {
      activated: (nativeDate) => {
        const date = new QDate(nativeDate as unknown as NativeElement);
        console.log(`activated: ${date.toString(DateFormat.SystemLocaleDate)}`);
      },
      clicked: (nativeDate) => {
        const date = new QDate(nativeDate as unknown as NativeElement);
        console.log(`clicked: ${date.toString(DateFormat.SystemLocaleDate)}`);
      },
      currentPageChanged: (year, month) => {
        console.log(`currentPageChanged: year, month: ${year}, ${month}`);
      },
      selectionChanged: () => {
        console.log("selectionChanged");
      },
    },
    []
  );

  return (
    <Window>
      <Calendar firstDayOfWeek={DayOfWeek.Sunday} on={calendarClickHandler} />
    </Window>
  );
};
Renderer.render(<App />);

@a7ul a7ul merged commit 2e6ac23 into nodegui:master Jul 7, 2022
@private-yusuke private-yusuke deleted the add-calendar branch July 7, 2022 10:24
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.

2 participants