# Cross-Platform Event-Definition

**URL:** <https://forum.xojo.com/t/cross-platform-event-definition/52770>\
**Category:** General\
**Created:** [March 15, 2020, 8:50pm UTC](https://forum.xojo.com/t/cross-platform-event-definition/52770 "2020-03-15T20:50:21Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Martin\_T](https://forum.xojo.com/letter_avatar_proxy/v4/letter/m/a88e57/32.png) [@Martin\_T](https://forum.xojo.com/u/Martin_T)\
**Post date:** [March 15, 2020, 8:50pm UTC](https://forum.xojo.com/t/cross-platform-event-definition/52770/1 "2020-03-15T20:50:21Z")

</div>

Hello,

i am currently writing a class that will be available for desktop, iOS and web.

You can select the target platform for a method in the second tab of the inspector. My problem now is that I want to give my class a paint event that is called via the Draw method. There are some subclasses of this class that use the paint event. However, I cannot specify a target platform for an event definition in the inspector. So I cannot create a cross-platform class, because for DrawiOS and DrawWeb i get the compiler error “Can’t find type with this name.”. Is there a workaround?

[code]Event PaintDesktop(g As Graphics)  
Event PaintiOS(g As iOSGraphics)  
Event PaintWeb(g As WebGraphics)

Sub DrawDesktop(g As Graphics)  
RaiseEvent PaintDesktop(g)  
End Sub

Sub DrawiOS(g As iOSGraphics)  
RaiseEvent PaintiOS(g)  
End Sub

Sub DrawWeb(g As WebGraphics)  
RaiseEvent PaintWeb(g)  
End Sub[/code]

---

<div class="post-metadata">

**Author:** ![Jean-Yves\_Pochez](https://forum.xojo.com/user_avatar/forum.xojo.com/jean-yves_pochez/32/21769_2.png) [@Jean-Yves\_Pochez](https://forum.xojo.com/u/Jean-Yves_Pochez)\
**Post date:** [March 15, 2020, 8:52pm UTC](https://forum.xojo.com/t/cross-platform-event-definition/52770/2 "2020-03-15T20:52:20Z")

</div>

can’t you override the method in the subclasses instead of using events ?

---

<div class="post-metadata">

**Author:** ![Christian\_Schmitz](https://forum.xojo.com/user_avatar/forum.xojo.com/christian_schmitz/32/158_2.png) [@Christian\_Schmitz](https://forum.xojo.com/u/Christian_Schmitz)\
**Post date:** [March 15, 2020, 9:06pm UTC](https://forum.xojo.com/t/cross-platform-event-definition/52770/3 "2020-03-15T21:06:46Z")

</div>

You “g as variant” and check what’s inside in the event.

---

<div class="post-metadata">

**Author:** ![Martin\_T](https://forum.xojo.com/letter_avatar_proxy/v4/letter/m/a88e57/32.png) [@Martin\_T](https://forum.xojo.com/u/Martin_T)\
**Post date:** [March 15, 2020, 9:15pm UTC](https://forum.xojo.com/t/cross-platform-event-definition/52770/4 "2020-03-15T21:15:54Z")

</div>

Of course I can also overwrite the methods. I just wanted to find out if this might be a missing feature in the Xojo IDE.  
\<[https://xojo.com/issue/59437](https://xojo.com/issue/59437)\> “Add Cross-Platform Event-Definition to IDE”

---

<div class="post-metadata">

**Author:** ![Norman\_Palardy](https://forum.xojo.com/user_avatar/forum.xojo.com/norman_palardy/32/169_2.png) [@Norman\_Palardy](https://forum.xojo.com/u/Norman_Palardy)\
**Post date:** [March 16, 2020, 1:28am UTC](https://forum.xojo.com/t/cross-platform-event-definition/52770/5 "2020-03-16T01:28:21Z")

</div>

Yeah dont call it drawIOS or DRawWeb etc  
simply call it “draw”  
then in draw you could use #if Target to select which one it calls internally

---

<div class="post-metadata">

**Author:** ![system](https://forum.xojo.com/uploads/default/original/1X/455b4dcc0e61630e9f81940004ddffa49c432a46.png) [@system](https://forum.xojo.com/u/system)\
**Post date:** [April 29, 2021, 4:19pm UTC](https://forum.xojo.com/t/cross-platform-event-definition/52770/6 "2021-04-29T16:19:17Z")

</div>


