-
Notifications
You must be signed in to change notification settings - Fork 6
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
Types in custom-electron-prompt #2
Comments
Ok submit a PR so that it can be tested 🙂 |
This is the first project I am collaborating on so I don't know how to add the types, can you explain like you did in the PR? |
Oh I thought you already had it. declaring types for exports might be too much since it varies so much between prompt options maybe we should just add a I'm not really proficient in typescript so i'm not sure about all this. needs testing |
oh I see. Anyway, there is one more problem I'm trying to solve. The click function is converted to String which has the benefit of using document on that window but there is also a drawback... Let's say if I have a class instance in my caller file and since everything is converted to a string, the instance foo is not passed not if I call |
its problematic to pass function with scopes from main process to renderer there is a prompt option (just have to make sure that script is loaded after the custom button has been created - so that the script can immediately have access to that button) custom-electron-prompt/lib/page/prompt.js Lines 97 to 127 in 88b9a31
|
Yeah, you're right. Right now I am using
and my caller class
|
Other that the types, can you look into this if you have some time. Thanks :) |
I'm not sure what you are trying to do here, if you want the button to set the input fields you could use $("#custom").onclick = () => {
$$("#data")[0].value = "?"
$$("#data")[1].value = "?"
} also in your current code - you have a memory leak - each time the button is clicked - it creates a new ipc listener and never closes it |
I am trying to get the position of mouse click from the user, so now each time the button is clicked it sends a message to the main class which waits for a click and then reply that position to the front. After receiving the position the X and Y are updated on the first and second input respectively. |
in that case maybe something like that in customScript, which shouldn't require ipc const getClickPos = require("./clickPos");
$("#custom").onclick = async () => {
const clickPos = await getClickPos();
$$("#data")[0].value = clickPos.x
$$("#data")[1].value = clickPos.y
} |
oh, great. Thanks |
Hello, i am using your prompt package in my electron typescript project and it works really well thanks for that! // src/types/custom-electron-prompt.d.ts
declare module "custom-electron-prompt" {
export interface PromptOptions {
width?: number;
height?: number;
resizable?: boolean;
title?: string;
label?: string;
buttonLabels?: { ok: string; cancel: string; };
value?: string;
type?: 'input' | 'select' | 'counter' | 'multiInput' | 'keybind';
selectOptions?: { [key: string]: string } | string[];
keybindOptions?: any;
counterOptions?: {
minimum?: number;
maximum?: number;
multiFire?: boolean;
};
icon?: string;
useHtmlLabel?: boolean;
customStylesheet?: string | boolean;
menuBarVisible?: boolean;
skipTaskbar?: boolean;
frame?: boolean;
customScript?: string;
enableRemoteModule?: boolean;
}
// This declares that the default export of the module is this function
export default function prompt(options: PromptOptions, parentWindow?: Electron.BrowserWindow): Promise<any>;
} so i was able to import your prompt via import instead of require like this: i also had to adapt my tsconfig.json and added the "types" folder to typeRoots: {
"compilerOptions": {
"target": "ESNext",
"module": "commonjs",
"allowJs": true,
"strict": false,
"skipLibCheck": true,
"esModuleInterop": true,
"noImplicitAny": true,
"sourceMap": true,
"baseUrl": ".",
"outDir": "dist",
"moduleResolution": "node",
"resolveJsonModule": true,
"jsx": "react-jsx",
"typeRoots": ["./node_modules/@types", "./types"], // <- here i added types
}
} |
I want to use this in a typescript project and I think having types would be useful here, most of them should be imported from the original repo only the changes have to be added.
EDIT: I'm willing to add my types(the work that I added), so you don't have a burden :)
The text was updated successfully, but these errors were encountered: