Of course, there's many many answers online about what it is, but I just can't wrap my head around it. I was hoping someone could give me an example of one using pascal/simba, maybe then I'll be able to understand.
Of course, there's many many answers online about what it is, but I just can't wrap my head around it. I was hoping someone could give me an example of one using pascal/simba, maybe then I'll be able to understand.
A callback function is usually just a method you pass to some class or structure (often a GUI form), so that it can notify you / your script if some event happens, like a key being pressed in a GUI form, so that you can do stuff in your GUI with that knowledge.
here is a very basic example:
Simba Code:procedure EventLoop(Callback: procedure); //this would normally be a form or similar
begin
IsMouseButtonDown(mouse_Left); //clear it (just ignore this)
while True do
begin
if IsMouseButtonDown(mouse_Left) then
Callback(); // Call the callback method to notify the scripter the mouse was pressed
Wait(50);
end;
end;
procedure MyCallbackFunc();
begin
WriteLn('The mouse was clicked, waiting till its released');
while IsMouseButtonDown(mouse_Left) do
Wait(50);
end;
begin
EventLoop(@MyCallbackFunc);
end.
RSWalker has some callbacks, like when you are walking it can call back to a function in your script so that you can for-example stop the walking half-way, or you can search for objects while it's walking, and such. Like every click RSW does, it can notify a method in your script about that click - that's the whole point of callbacks.
Last edited by slacky; 03-08-2018 at 07:54 AM.
!No priv. messages please
Alright I get it, I think. I think an issue I'm having is I haven't ever encountered a situation where I would need this. I suppose it'll solidify in my mind if I ever actually need to make use of it.. Thanks slacky
edit: missed your RSWalker example. Okay now I think I really do get it. So I assume with the RSWalker example, you can just choose to run whichever procedure inside of the RSW click. Yeah I can see why that'd be useful
bump having trouble I think this is my solution... but the example online don't really apply they are difficult to understand
I have am listening to the keyboard with winapi, and when I press a certain button I need it to be unhooked, and then rehooked. can unhook fine, but the problem is rehooking.
or maybe its this fucking loop
[codewhile (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}[/code]
There are currently 1 users browsing this thread. (0 members and 1 guests)