Tk_CreateSelHandler(3)
β¨ NAME β¨
okay bestie, this is the Tk Library Procedures page for Tk_CreateSelHandler and Tk_DeleteSelHandler β the duo that will arrange to handle requests for a selection π«Άπ
. One creates the handler, one deletes it, and both are fully about selection requests, no cap.
π¦ SYNOPSIS π¦
First you include Tk like this, bestie:
#include <tk.h>
then the two calls are literally:
Tk_CreateSelHandler(tkwin, selection, target, proc, clientData, format)
Tk_DeleteSelHandler(tkwin, selection, target)
that's the exact shape β¨π
π ARGUMENTS π
every single arg, no skipping, no βIβll read it laterβ energy:
Tk_Window tkwin(in) β the window for whichprocwill provide selection information. πͺAtom selection(in) β the name of the selection for whichprocwill provide selection information. π·οΈAtom target(in) β the form in whichproccan provide the selection (e.g.STRINGorFILE_NAME). This corresponds to the type arguments in selection commands. π―Tk_SelectionProc *proc(in) β the procedure to invoke whenever the selection is owned bytkwinand the selection contents are requested in the format given bytarget. πvoid *clientData(in) β arbitrary one-word value to pass toproc. π«ΆAtom format(in) β if the selection requestor is not in this process,formatdetermines the representation used to transmit the selection to its requestor. π¦
πΈ DESCRIPTION πΈ
Tk_CreateSelHandler arranges for a particular procedure (proc) to be called whenever selection is owned by tkwin and the selection contents are requested in the form given by target. target should be one of the entries defined in the left column of Table 2 of the X Inter-Client Communication Conventions Manual (ICCCM), or any other form in which an application is willing to present the selection. The most common form is STRING. πβ¨
proc should have arguments and result that match the type Tk_SelectionProc:
typedef Tcl_Size Tk_SelectionProc(
void *clientData,
Tcl_Size offset,
char *buffer,
Tcl_Size maxBytes);
The clientData parameter to proc is a copy of the clientData argument given to Tk_CreateSelHandler. Typically, clientData points to a data structure containing application-specific information that is needed to retrieve the selection. offset specifies an offset position into the selection, buffer specifies a location at which to copy information about the selection, and maxBytes specifies the amount of space available at buffer. proc should place a NULL-terminated string at buffer containing maxBytes or fewer characters (not including the terminating NULL), and it should return a count of the number of non-NULL characters stored at buffer. If the selection no longer exists (e.g. it once existed but the user deleted the range of characters containing it), then proc should return -1. ππ
When transferring large selections, Tk will break them up into smaller pieces (typically a few thousand bytes each) for more efficient transmission. It does this by calling proc one or more times, using successively higher values of offset to retrieve successive portions of the selection. If proc returns a count less than maxBytes, it means that the entire remainder of the selection has been returned. If proc's return value is maxBytes, it means there may be additional information in the selection, so Tk must make another call to proc to retrieve the next portion. ππ«
proc always returns selection information in the form of a character string. However, the ICCCM allows for information to be transmitted from the selection owner to the selection requestor in any of several formats, such as a string, an array of atoms, an array of integers, etc. The format argument to Tk_CreateSelHandler indicates what format should be used to transmit the selection to its requestor (see the middle column of Table 2 of the ICCCM for examples). If format is not STRING, then Tk will take the value returned by proc and divide it into fields separated by white space. If format is ATOM, then Tk will return the selection as an array of atoms, with each field in proc's result treated as the name of one atom. For any other value of format, Tk will return the selection as an array of 32-bit values where each field of proc's result is treated as a number and translated to a 32-bit value. In any event, the format atom is returned to the selection requestor along with the contents of the selection. ππ
If Tk_CreateSelHandler is called when there already exists a handler for selection and target on tkwin, then the existing handler is replaced with a new one. π₯
Tk_DeleteSelHandler removes the handler given by tkwin, selection, and target, if such a handler exists. If there is no such handler, then it has no effect. π«Ά
π₯ KEYWORDS π₯
format, handler, selection, target β that's the keyword lineup, bestie ππ
okay that's the whole page! source/version: Tk, version 4.0 β Tk_CreateSelHandler(3) signing off π
β¨π (date: not listed in the footer, so we are absolutely not inventing one ππ«Ά)
π¦ where this page comes from
- alpine 3.23: tk9-doc 9.0.3-r0 Β· TCL
- alpine 3.24: tk9-doc 9.0.3-r2 Β· TCL
- fedora 43: tk-devel 1:9.0.2-1.fc43 Β· TCL AND HPND-Pbmplus AND CC-BY-SA-3.0 AND MIT-open-group AND MIT
- fedora 43: tk-devel 1:9.0.2-1.fc43 Β· TCL AND HPND-Pbmplus AND CC-BY-SA-3.0 AND MIT-open-group AND MIT
- fedora 44: tk-devel 1:9.0.2-1.fc44 Β· TCL AND HPND-Pbmplus AND CC-BY-SA-3.0 AND MIT-open-group AND MIT
- fedora 44: tk-devel 1:9.0.2-1.fc44 Β· TCL AND HPND-Pbmplus AND CC-BY-SA-3.0 AND MIT-open-group AND MIT
- nixos 26.05: tk 9.0.3
- nixpkgs unstable: tk 9.1.0
- Copyright (c) 1990-1994 The Regents of the University of California
- Copyright (c) 1994-1996 Sun Microsystems, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms