Difference between revisions of "Talk:CudaText API"
From Lazarus wiki
Jump to navigationJump to searchLine 38: | Line 38: | ||
** "mmm.nnn" - the same, to call method, short form | ** "mmm.nnn" - the same, to call method, short form | ||
** "module=mmm;func=nnn;" - to call function nnn in root of module mmm | ** "module=mmm;func=nnn;" - to call function nnn in root of module mmm | ||
+ | |||
+ | ====Actions==== | ||
+ | |||
+ | Param prop: it can be of any simple type (str, int, bool), also tuple/list (of any simple type), also dict (keys: str, values: simple type or tuple/list). Most used is dict. Example of control props: prop={"cap": "...", "x": 10, "y": 10, "w": 600, "en": False}. | ||
+ | |||
+ | Param id_dialog: int, form handle. Ignored only for DLG_CREATE (pass 0). | ||
+ | |||
+ | Possible values of id_action: | ||
+ | |||
+ | * DLG_CREATE: Creates new form, gets form handle. | ||
+ | * DLG_HIDE: Hides from. | ||
+ | * DLG_FREE: Hides and deletes form. | ||
+ | * DLG_SHOW_MODAL: Shows form in modal mode (blocks input to other forms). | ||
+ | * DLG_SHOW_NONMODAL: Shows form in non-modal mode. | ||
+ | * DLG_FOCUS: Focuses form (in non-modal mode). | ||
+ | * DLG_PROP_GET: Gets form props, as dict. | ||
+ | * DLG_PROP_SET: Sets from props. Param "prop" is dict with props. See example above, see list of possible form props. | ||
+ | * DLG_CTL_COUNT: Gets count of controls on form. | ||
+ | * DLG_CTL_ADD: Adds new control to form, gets its index, or None if cannot add. Param "prop" is type of control. See description in dlg_custom. | ||
+ | * DLG_CTL_PROP_GET: Gets control props, as dict. Param "index" is index of control (0 to count-1). | ||
+ | * DLG_CTL_PROP_SET: Sets control props. Param "index" is index of control. Param "prop" is dict with props. | ||
+ | * DLG_CTL_DELETE: Deletes control. Param "index" is index of control. | ||
+ | * DLG_CTL_DELETE_ALL: Delets all controls. | ||
+ | * DLG_CTL_FOCUS: Focuses control. Param "index" is index of control. | ||
+ | * DLG_CTL_FIND_NAME: Gets index of control by its name. Param "prop" is name. | ||
+ | * DLG_CTL_HANDLE: Gets int handle of control. Useful only for few control types: for "listbox" this handle can be used in listbox_proc(). | ||
+ | * DLG_COORD_LOCAL_TO_SCREEN: Converts x/y coordinates from form-related, to screen-related. Param "index" is x, "index2" is y. Gets tuple (x,y). | ||
+ | * DLG_COORD_SCREEN_TO_LOCAL: Converts x/y coordinates from screen-related, to form-related. Param "index" is x, "index2" is y. Gets tuple (x,y). |
Revision as of 21:53, 15 April 2017
(no text)
Dlg_proc (temp text)
dlg_proc
dlg_proc(id_dialog, id_action, prop="", index=-1, index2=-1)
Advanced work with dialogs. More advanced than dlg_custom(), e.g. dialogs can show as modal/nonmodal.
Form properties
- "cap": str: Caption of form.
- "x", "y": int: Position (screen coordinates), left/top.
- "w", "h": int: Size, width/height.
- "w_min", "w_max": int: Constraints for width, min/max value.
- "h_min", "h_max": int: Constraints for height, min/max value.
- "resize": bool: If on, allows form to resize.
Control properties
- "name": str: Optional word-like string, name of control, to find control later by name.
- "cap": str: Caption of control.
- "x", "y": int: Position (coordinates relative to dialog), left/top.
- "w", "h": int: Size, width/height.
- "en": bool: Enabled state.
- "vis": bool: Visible state.
- "font": str: Font props, in the form "font_name,int_font_size,int_font_color".
- "hint": str: Hint (tooltip) for mouse-over. Newlines must be "\r".
- "act": bool: Active state. For active control, change of value calls the event (on_dlg or custom callback). Buttons are active by default.
- "props": str: Advanced control-specific props. Described in dlg_custom.
- "items": str: Usually tab-separated items. Described in dlg_custom.
- "val": str: Value of control. Described in dlg_custom.
- "tag": str: Any string, set by plugin.
- "callback": str: If not empty, active control calls this callback instead of on_dlg event. Has one of forms:
- "module=mmm;cmd=nnn;" - to call method nnn (in class Command) in plugin mmm (mmm is usually subfolder in the "cudatext/py", but can be any module name)
- "mmm.nnn" - the same, to call method, short form
- "module=mmm;func=nnn;" - to call function nnn in root of module mmm
Actions
Param prop: it can be of any simple type (str, int, bool), also tuple/list (of any simple type), also dict (keys: str, values: simple type or tuple/list). Most used is dict. Example of control props: prop={"cap": "...", "x": 10, "y": 10, "w": 600, "en": False}.
Param id_dialog: int, form handle. Ignored only for DLG_CREATE (pass 0).
Possible values of id_action:
- DLG_CREATE: Creates new form, gets form handle.
- DLG_HIDE: Hides from.
- DLG_FREE: Hides and deletes form.
- DLG_SHOW_MODAL: Shows form in modal mode (blocks input to other forms).
- DLG_SHOW_NONMODAL: Shows form in non-modal mode.
- DLG_FOCUS: Focuses form (in non-modal mode).
- DLG_PROP_GET: Gets form props, as dict.
- DLG_PROP_SET: Sets from props. Param "prop" is dict with props. See example above, see list of possible form props.
- DLG_CTL_COUNT: Gets count of controls on form.
- DLG_CTL_ADD: Adds new control to form, gets its index, or None if cannot add. Param "prop" is type of control. See description in dlg_custom.
- DLG_CTL_PROP_GET: Gets control props, as dict. Param "index" is index of control (0 to count-1).
- DLG_CTL_PROP_SET: Sets control props. Param "index" is index of control. Param "prop" is dict with props.
- DLG_CTL_DELETE: Deletes control. Param "index" is index of control.
- DLG_CTL_DELETE_ALL: Delets all controls.
- DLG_CTL_FOCUS: Focuses control. Param "index" is index of control.
- DLG_CTL_FIND_NAME: Gets index of control by its name. Param "prop" is name.
- DLG_CTL_HANDLE: Gets int handle of control. Useful only for few control types: for "listbox" this handle can be used in listbox_proc().
- DLG_COORD_LOCAL_TO_SCREEN: Converts x/y coordinates from form-related, to screen-related. Param "index" is x, "index2" is y. Gets tuple (x,y).
- DLG_COORD_SCREEN_TO_LOCAL: Converts x/y coordinates from screen-related, to form-related. Param "index" is x, "index2" is y. Gets tuple (x,y).