RaiseEvent

me thought that events processed if a method ends.
if you use RaiseEvent for a event devinition inside a class this event is direct executed.
its a fake event and just execute the method for?

xojo 2019r3.1 windows desktop project

events are executed when raised, as long as there is an implementation (obviously)

otherwise code like

dim maxCount as integer = raiseEvent GetCount()

for i as integer = 0 to maxCount
   // do some work here
next

would not ever work properly and I can assure you it does

[quote=494188:@Norman Palardy][/quote]
yep. with a return value it make sense to call this method behind direct.
seems other things like mouse clicks or timers are not processed if a method is not finished.
thats why i thought own events would also executed later.

System events, like mouse clicks and timers, are processed in the main thread’s event loop, which runs outside your code, when your code is not running. Events you raise run inside your code and happen immediately, like a method call.

i need a solution if many computed propertys changed the object i would do a task once and not duplicative.
as example after load the data and put them all into objects.
maybe i can do this with flags and a timer.

i am still struggle with events occur by user or code.
as example if me load and setup data into a object i do not want raise a changed event because modifications can cause a auto save.
now it is a flag that i remove after loading. but in this case i just do not want set this changed flag and i think its risky.
if me load objects one by one they need a arrangement in the ui. the add method raise a event for a new arrangement .
but at load i need this only once after all objects was load. now i have a extra parameter at the Add method to prevent
the arrangement and call the arrangement for all after load. I don’t like this.
a flag with events on & off did not work because some events must processed always at least once.
i think i need a event management class.

What I do is subclass each control and add an extra method to set the value of the control. In that method I set a flag and then clear it. For example, for a TextField I have a SetText method and a property ChangedInCode as Boolean.

Sub SetText(s as string)
   ChangedInCode = True
   me.Text = s
   ChangedInCode = False
End Sub

Then I can test the ChangedInCode flag in the TextChanged event and act accordingly. This encapsulates the flag in the control itself and minimizes any negative consequences of have a global flag that could be set incorrectly.

thank you tim

i think i can not use it consistently, some events i need and others not.
i have a hierarchy of controls it looks like

main control
         sub control
                  sub control
                  sub control
                  sub control
         sub control
                  sub control
                  sub control
                  sub control

and i use raise event for communication what to do next.
i stumble at my own events.
redraw,position,changed,selected,delete,newsize,…
it looks chaotic in source code and i lost the overview somehow.

what i need is something like a task list, i could visualize it to verify.
and i would have a central place for execute this tasks (events).
questionable if this rebuild is worth the effort.

Why not? That seems like the correct approach.

Markus, in case you were not aware of this:

If you expect to handle several pending Event that all come right after each other, e.g the combination of LostFocus and GotFocus on different controls, and you want to do something once all these are done, then you can use a Timer for this, because a Timer never fires in the current event from which you start it, but always in the next time the app is fetching new events from the OS (like mouse clicks, keyboard typing etc., or a pending Timer event). So, you’d set the Timer’s Period to 0 and its Mode to 1 (single). Then, in the Action handler, do your stuff.

because the Add Method is the indicator that a new position at ui is needed.
why it affects all other items i don’t know yet. at least i updated all other items after the Add method.
now i have a flag for the Add method that is does not updates others and after Load i calculate all item positions.
i think i update also the scrollbar and need the complete height of all controls.
maybe its wrong that i change or update all others after the Add method.
i need to reconsider why i have this done so.

[quote=494702:@Thomas Tempelmann]Markus, in case you were not aware of this:

If you expect to handle several pending Event that all come right after each other, e.g the combination of LostFocus and GotFocus on different controls, and you want to do something once all these are done, then you can use a Timer for this, because a Timer never fires in the current event from which you start it, but always in the next time the app is fetching new events from the OS (like mouse clicks, keyboard typing etc., or a pending Timer event). So, you’d set the Timer’s Period to 0 and its Mode to 1 (single). Then, in the Action handler, do your stuff.[/quote]

yes it was my consideration but i need to test what happened if i create a event multiple in case i want only one execution.

I must admit I have trouble understanding what you’re asking. Have you tried asking in the German forum instead? Unless you have already found your answer.