Hello @Zorcal welcome to ziggit
The inner struct function cannot access outer local variables. It can access global variables.
When handlers are called, the normal execution of your program is interrupted in some unknown state.
Your best strategy is to do almost nothing in the handler; just notify the program about the change e.g. by raising a flag. Then your main program loop can handle the resize.