OOP Question
BlitzMax Forums/BlitzMax Programming/OOP Question
| ||
Given the a TGadget object as the field to a type. Is it possible get type which contains that field so that a method can be called automatically? Type My Field test:TGadget Method Update() x=x+1 End Method End Type ..... local MyObj:my=New my If ( EventSource()=MyObj.Test ) MyObj.Update End If ^ | I want the above To be automatic Something like EventSource().Update |
| ||
Is this in anyway possible? |
| ||
If you replace My with an actual object, then this is how it works at the moment. But if you let it be My (the type itself), you can't access field / method, only globa l/ const / function. |
| ||
Sorry, I did mean the my was the object and I have updated the code in the first post accordingly (hopefully). The idea is that that "my" is a type that includes a label, text box and slider with methods to update the text based on the slider position and update the slider position based on the text input. The GUI will be a collection of these (around 30). The case statement looking at each text box and slider is huge and I thought there must be a better way to do this. If the eventsource() is MyObj.Test (i.e. the slider) can I find MyObj so that I can call the MYObj method to update the associated text box? RJJ |
| ||
why dont you just create a listType My Field test:TGadget Method Update() x=x+1 End Method End Type '..... Local MyObjList:Tlist = CreateList() Local mytestobj:my = CreateMyObj() For Local myobj:my = EachIn MyObjList If ( EventSource()=MyObj.Test ) MyObj.Update() End If Next Function CreateMyObj:My() Local myobj:my = New my MyObjList.addlast myobj Return myobj End Function somthing like that should work |
| ||
RJJ: if you add a field / global x that can be raised then yes, thats correct working source. |
| ||
Diablo: Thanks the list is a good solution. Dreamora: The issue isn't really the syntax. What I want to know is whether given the field test you can derive its object so that you can call the method update for that that instance. Thanks |