📄 sdlseteventfilter.html
字号:
<HTML><HEAD><TITLE>SDL_SetEventFilter</TITLE><METANAME="GENERATOR"CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+"><LINKREL="HOME"TITLE="SDL Library Documentation"HREF="index.html"><LINKREL="UP"TITLE="Event Functions."HREF="eventfunctions.html"><LINKREL="PREVIOUS"TITLE="SDL_PushEvent"HREF="sdlpushevent.html"><LINKREL="NEXT"TITLE="SDL_GetEventFilter"HREF="sdlgeteventfilter.html"></HEAD><BODYCLASS="REFENTRY"BGCOLOR="#FFF8DC"TEXT="#000000"LINK="#0000ee"VLINK="#551a8b"ALINK="#ff0000"><DIVCLASS="NAVHEADER"><TABLESUMMARY="Header navigation table"WIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><THCOLSPAN="3"ALIGN="center">SDL Library Documentation</TH></TR><TR><TDWIDTH="10%"ALIGN="left"VALIGN="bottom"><AHREF="sdlpushevent.html"ACCESSKEY="P">Prev</A></TD><TDWIDTH="80%"ALIGN="center"VALIGN="bottom"></TD><TDWIDTH="10%"ALIGN="right"VALIGN="bottom"><AHREF="sdlgeteventfilter.html"ACCESSKEY="N">Next</A></TD></TR></TABLE><HRALIGN="LEFT"WIDTH="100%"></DIV><H1><ANAME="SDLSETEVENTFILTER"></A>SDL_SetEventFilter</H1><DIVCLASS="REFNAMEDIV"><ANAME="AEN5575"></A><H2>Name</H2>SDL_SetEventFilter -- Sets up a filter to process all events before they are posted to the event queue.</DIV><DIVCLASS="REFSYNOPSISDIV"><ANAME="AEN5578"></A><H2>Synopsis</H2><DIVCLASS="FUNCSYNOPSIS"><ANAME="AEN5579"></A><P></P><PRECLASS="FUNCSYNOPSISINFO">#include "SDL.h"</PRE><P><CODE><CODECLASS="FUNCDEF">void <BCLASS="FSFUNC">SDL_SetEventFilter</B></CODE>(SDL_EventFilter filter);</CODE></P><P></P></DIV></DIV><DIVCLASS="REFSECT1"><ANAME="AEN5585"></A><H2>Description</H2><P>This function sets up a filter to process all events before they are posted to the event queue. This is a very powerful and flexible feature. The filter is prototyped as:<PRECLASS="PROGRAMLISTING">typedef int (*SDL_EventFilter)(const SDL_Event *event);</PRE>If the filter returns <SPANCLASS="RETURNVALUE">1</SPAN>, then the event will be added to the internal queue. If it returns <SPANCLASS="RETURNVALUE">0</SPAN>, then the event will be dropped from the queue. This allows selectivefiltering of dynamically.</P><P>There is one caveat when dealing with the <TTCLASS="LITERAL">SDL_QUITEVENT</TT> event type. Theevent filter is only called when the window manager desires to close theapplication window. If the event filter returns 1, then the window willbe closed, otherwise the window will remain open if possible.If the quit event is generated by an interrupt signal, it will bypass theinternal queue and be delivered to the application at the next event poll.</P><DIVCLASS="NOTE"><BLOCKQUOTECLASS="NOTE"><P><B>Note: </B>Events pushed onto the queue with <AHREF="sdlpushevent.html"><TTCLASS="FUNCTION">SDL_PushEvent</TT></A> or <AHREF="sdlpeepevents.html"><TTCLASS="FUNCTION">SDL_PeepEvents</TT></A> do not get passed through the event filter.</P></BLOCKQUOTE></DIV><DIVCLASS="NOTE"><BLOCKQUOTECLASS="NOTE"><P><B>Note: </B><SPANCLASS="emphasis"><ICLASS="EMPHASIS">Be Careful!</I></SPAN> The event filter function may run in a different thread so be careful what you do within it.</P></BLOCKQUOTE></DIV></DIV><DIVCLASS="REFSECT1"><ANAME="AEN5602"></A><H2>See Also</H2><P><AHREF="sdlevent.html"><SPANCLASS="STRUCTNAME">SDL_Event</SPAN></A>,<AHREF="sdlgeteventfilter.html"><TTCLASS="FUNCTION">SDL_GetEventFilter</TT></A>,<AHREF="sdlpushevent.html"><TTCLASS="FUNCTION">SDL_PushEvent</TT></A></P></DIV><DIVCLASS="NAVFOOTER"><HRALIGN="LEFT"WIDTH="100%"><TABLESUMMARY="Footer navigation table"WIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top"><AHREF="sdlpushevent.html"ACCESSKEY="P">Prev</A></TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="index.html"ACCESSKEY="H">Home</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top"><AHREF="sdlgeteventfilter.html"ACCESSKEY="N">Next</A></TD></TR><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top">SDL_PushEvent</TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="eventfunctions.html"ACCESSKEY="U">Up</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top">SDL_GetEventFilter</TD></TR></TABLE></DIV></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -