When was a trebeuchet or any similar weapons (such as an onager, mangonel, catapult) last used in combat?

My guess is that they were replaced by the cannon in the gunpowder age. But I know the cannon was not adopted by everyone at the same time.

So how long exactly was the trebuchet still in use in military warfare?

I'm speaking specifically in terms of military combat, and not its uses in commercial or industrial activities.