ImageButton device add mousemove event OnRuntime

pdabasic

Active Member
Licensed User
Hello!

I tried to make alphabet list width imagebuttom and I need to attach the mouse move event all buttons.

Now it look like:
B4X:
Sub list_create
  alphabet()=Array("A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z")
   For i=0 To ArrayLen(alphabet())-1
      AddImageButton("main.frmMain","btnListAlpha"&alphabet(i),430,10+26*i,50,26,alphabet(i))
      ImageButton("btnListAlpha"&alphabet(i)).FontSize=12
      ImageButton("btnListAlpha"&alphabet(i)).Visible=False
      
      AddEvent("btnListAlpha"&alphabet(i),Click,"mys_list_alpha_click")
      AddEvent("btnListAlpha"&alphabet(i),ButtonDown,"mys_list_alpha_down")
      AddEvent("btnListAlpha"&alphabet(i),ButtonUp,"mys_list_alpha_up")
      AddObject("doorObj"&alphabet(i),"Object")
      AddObject("doorObjProp"&alphabet(i),"Object")
      Object("doorObj"&alphabet(i)).New1(False)
      Object("doorObjProp"&alphabet(i)).New1(False)
      Object("doorObj"&alphabet(i)).FromControl("btnListAlpha"&alphabet(i))
      AddObject("doorEventMove"&alphabet(i),"Event")
      Event("doorEventMove"&alphabet(i)).New1(Object("doorObj"&alphabet(i)).Value,"MouseMove")
   Next
End Sub

Sub mouse_move(x,y)
...
End Sub

Sub doorEventMove[COLOR="Red"]A[/COLOR]_NewEvent
  Object("doorObjProp"&alphabet([COLOR="Red"]0[/COLOR])).Value=Event("doorEventMove"&alphabet([COLOR="Red"]0[/COLOR])).Data
  mouse_move(Event(Object("doorObjProp"&alphabet([COLOR="Red"]0[/COLOR])).GetProperty("X"),Object("doorObjProp"&alphabet([COLOR="Red"]0[/COLOR])).GetProperty("Y")
End Sub

[B]More 25x:[/B]
Sub doorEventMove[COLOR="Red"]B[/COLOR]_NewEvent
...

How can I do it easier?
 

mjcoon

Well-Known Member
Licensed User
Well, I'd probably put the alphabet in a string rather than an array and pick letters out using StrAt(), but that does not address the meat of your question.

Which I cannot answer because I am a door.dll virgin. And do not understand what you are doing with all those events anyway. Is ordinary imagebutton behaviour inadequate?

Mike.
 

mjcoon

Well-Known Member
Licensed User
The original ImageButton have no mousemove(x,y) Event, or have It?!

I have no idea. But I would guess not because a user would expect that a button is either touched or is not. Where within the button it is touched or whether the mouse moves is not normally taken account of. But of course that does not prevent an innovative designer being more inventive; it may be something more people find interesting if you can make it work! BTW What pixel location will the (x, y) parameters be relative to? I have only used mouse move relative to the form.

(N.B. I don't know anything about sprite behaviour either or whether it is possible to interact with a sprite.)

Mike.
 

pdabasic

Active Member
Licensed User
What pixel location will the (x, y) parameters be relative to? I have only used mouse move relative to the form.

MouseMove on imagebutton represent the mouse x,y position on the button.

I need it because I would like to set a value on my imagebutton list when I hold down my finger and move for example from A to B.

If the y value=0 And the next y value=prewbutton heigh then call to prewbutton event Else if y value=button height and the next y=0 then call to nextbutton event

Now it's work fine but now I must to write all element mouse move event separetly.
 

pdabasic

Active Member
Licensed User
I wouldn't use a lot of ImageButtons but draw the characters on the Form background and use the Form MouseEvents. In the MouseEvent routine you can calculate at what character you are and decide what you need to do.

Best regards.

Thank you for your suggestion.
Other case I will use this but now I need the imagebutton other possibilities too.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…