Class problem

Scraatch

Well-Known Member
Joined
Jan 14, 2017
Messages
48
Likes
2
Points
23
Location
Germany
#1
Hey there

i have this class and i tried to use it but only the function create() works, the other funcs doenst works.

Class
Code:
class textdraw{
    ident := -1
    text := "NOTEXT"
    xpos := 0
    ypos := 0
    letterColor := "0xFFFF901E"
    font := 3
    letterWidth := 0.28
    letterHeight := 1.0
    shadowSize := 0
    outline := 1
    shadowColor := 0xFF000000
    box := 0
    boxColor := 0xFFFFFFFF
    boxSizeX := 0.0
    boxSizeY := 0.0
    left := 0
    right := 0
    center := 1
    proportional := 1
    modelID := 0
    xRot := 0.0
    yRot := 0.0
    zRot := 0.0
    zoom := 1.0
    color1 := 0xFFFF
    color2 := 0xFFFF
    testtext := "-"

    create(){
        This.ident := createTextDraw(This.text, This.xpos, This.ypos, This.letterColor, This.font, This.letterWidth, This.letterHeight, This.shadowSize, This.outline, This.shadowColor, This.box, This.boxColor, This.boxSizeX, This.boxSizeY, This.left, This.right, This.center, This.proportional, This.modelID, This.xRot, This.yRot, This.zRot, This.zoom, This.color1, This.color2)
    }

    delete(){
        deleteTextDraw(This.ident)
        This.ident := -1
    }

    update(newtext){
        updateTextDraw(This.ident, newtext)
    }

    move(xpos, ypos){
        moveTextDraw(This.ident, xpos, ypos)
    }
}
Usement
Code:
CMD_Create(){
    TD_Test := New textdraw
    TD_Test.text := "Test"
    TD_Test.xpos := 100
    TD_Test.ypos := Round(getPageSize() * 8.5 + 45.0, 1)
    TD_Test.create()
}

CMD_Delete(){
    TD_Test.delete()
}

CMD_Move(params := ""){
    RegExMatch(params, "(.*) (.*)", pos)
    TD_Test.move(pos1, pos2)
}

CMD_Update(params := ""){
    TD_Test.update(params)
}
I think there is a problem to save the createTextdraw function into the variable ident
 

user88

Well-Known Member
Joined
Jun 29, 2017
Messages
333
Likes
125
Points
48
Location
Bajaje
15
#3
Code:
//define outside of any function will solve.. ( AHK destroyes the object when the function is done, wher it was defined.)!
global TD_Test := New textdraw
 
Top