Android Question ZoomImageView2,how to add new event:CallSubAnyArgs(ParamArray args())

xiaoyao

Active Member
Licensed User
Longtime User
Sub Sum (ParamArray intNums ())


Error description: Too many parameters.
An error occurs in the following line: 257
:257
CallSub3(mCallBack, mEventName & "_ZoomEvent", CurrentScale, CenterX, CenterY)
word: _ref

B4X:
Else if Action = pnl.TOUCH_ACTION_UP Then
        TouchDown = False
 
[B]how to CallSub4,CallSub5?CallSub(any args?:confused:[/B]
 
                  
        If DateTime.Now - ClickStart < ClickThreshold And DisableClickEvent = False Then
            Sleep(1)
            If xui.SubExists(mCallBack, mEventName & "_ZoomEvent", 3) Then
                CallSub3(mCallBack, mEventName & "_ZoomEvent", CurrentScale, CenterX, CenterY)
            End If
      
            If xui.SubExists(mCallBack, mEventName & "_Click", 0) Then
                CallSub(mCallBack, mEventName & "_Click")
            End If
        End If
B4X:
Private Sub ZoomChanged (x As Int, y As Int, ZoomDelta As Float)
    Dim ivx As Float = x - pnlBackground.Left
    Dim ivy As Float = y - pnlBackground.Top
    ZoomDelta = Max(ZoomDelta, mBase.Width / pnlBackground.Width)
    pnlBackground.SetLayoutAnimated(0, x - ivx * ZoomDelta, y - ivy * ZoomDelta, pnlBackground.Width * ZoomDelta, pnlBackground.Height * ZoomDelta)
    SetImageViewLayout
    UpdateScaleAndCenter
 
    If xui.SubExists(mCallBack, mEventName & "_ZoomEvent", 3) Then
        CallSub3(mCallBack, mEventName & "_ZoomEvent", CurrentScale, CenterX, CenterY)
    End If
      
End Sub
 

Attachments

  • ZoomImageView2.zip
    3.3 KB · Views: 4
Last edited:

xiaoyao

Active Member
Licensed User
Longtime User
how to load pictures auto zoom to (2.3,showPIC x,y)?
how to cpy function info by tips?

Private Sub ZoomImageView1_ZoomEvent(CurrentScale As Float, CenterX As Float, CenterY As Float)

txt1.Text= CurrentScale & ",xy=" & CenterX & "," & CenterY
End Sub
COPY_EVENT_function info.png
 
Upvote 0

Sagenut

Expert
Licensed User
Longtime User
You do not need to copy the intellisense hint.
When you will write the command
B4X:
ZoonImageView1.SetBitmapEX(
then the hint will come up by itself indicating you which parameters are needed.
 
Upvote 0

Sagenut

Expert
Licensed User
Longtime User
Error description: Too many parameters.
An error occurs in the following line: 257
:257
CallSub3(mCallBack, mEventName & "_ZoomEvent", CurrentScale, CenterX, CenterY)
word: _ref

B4X:
Else if Action = pnl.TOUCH_ACTION_UP Then
        TouchDown = False
 
[B]how to CallSub4,CallSub5?CallSub(any args?:confused:[/B]
 
                 
        If DateTime.Now - ClickStart < ClickThreshold And DisableClickEvent = False Then
            Sleep(1)
            If xui.SubExists(mCallBack, mEventName & "_ZoomEvent", 3) Then
                CallSub3(mCallBack, mEventName & "_ZoomEvent", CurrentScale, CenterX, CenterY)
            End If
     
            If xui.SubExists(mCallBack, mEventName & "_Click", 0) Then
                CallSub(mCallBack, mEventName & "_Click")
            End If
        End If
B4X:
Private Sub ZoomChanged (x As Int, y As Int, ZoomDelta As Float)
    Dim ivx As Float = x - pnlBackground.Left
    Dim ivy As Float = y - pnlBackground.Top
    ZoomDelta = Max(ZoomDelta, mBase.Width / pnlBackground.Width)
    pnlBackground.SetLayoutAnimated(0, x - ivx * ZoomDelta, y - ivy * ZoomDelta, pnlBackground.Width * ZoomDelta, pnlBackground.Height * ZoomDelta)
    SetImageViewLayout
    UpdateScaleAndCenter
 
    If xui.SubExists(mCallBack, mEventName & "_ZoomEvent", 3) Then
        CallSub3(mCallBack, mEventName & "_ZoomEvent", CurrentScale, CenterX, CenterY)
    End If
     
End Sub
If you need to pass many parameters then you should use CallSub2 and put a Map, a List or a Type with all what you need to pass as a unique parameter.
 
Upvote 0

xiaoyao

Active Member
Licensed User
Longtime User
If you need to pass many parameters then you should use CallSub2 and put a Map, a List or a Type with all what you need to pass as a unique parameter.

can b4a,b4i make new method callbyname(obj,methodanme,anyargs)
like vb6 ParamArray



ASP.net:
Sub Sum (ParamArray intNums ())
   For Each x In intNums
      y = y + x
   Next x
   intSum = y
End Sub
call    Sum (1, 3, 5, 7, 8)
result= Sum (1, 3, 5, 7, 8)

Java:
public class ClassB {
    public String downurl(String url, int timeout, String CHARSET) {
        System.out.println("URL:" + url);
        System.out.println("Timeout:" + timeout);
        System.out.println("Charset:" + CHARSET);
        return "Download completed";
    }
}

Java:
import java.lang.reflect.Method;
 
public class CallMethodUtil {
    public static Object callMethod(Object obj, String methodName, Object... params) throws Exception {
        Class<?> clazz = obj.getClass();
        Class<?>[] paramTypes = new Class[params.length];
        for (int i = 0; i < params.length; i++) {
            paramTypes[i] = params[i].getClass();
        }
        Method method = clazz.getMethod(methodName, paramTypes);
        return method.invoke(obj, params);
    }
}

Java:
 ClassB b = new ClassB();
            Object result = CallMethodUtil.callMethod(
                b,
                "downurl",
                "https://www.baidu.com",
                5000,
                "UTF-8"
            );
            System.out.println("Return result:" + result);
 
Upvote 0

xiaoyao

Active Member
Licensed User
Longtime User
You do not need to copy the intellisense hint.
When you will write the command
B4X:
ZoonImageView1.SetBitmapEX(
then the hint will come up by itself indicating you which parameters are needed.

SOME METHOD TIP INFO, I want to copy the event definition and description of the library to AI or browser, and translate them into the language and script of my country

can b4a ide make new tips:
event ZoonImageView1_??
LIKE SUB CONTROL_CLICK



Can we add a new syntax keyword?
Event ControlName_EventName(args)


it will show you :ZoonImageView1_click()
ZoonImageView1_zoomEvent(**)
 
Last edited:
Upvote 0

aeric

Expert
Licensed User
Longtime User
You can type Sub and press Tab.
Intellisense will list out the available objects.
Select the object you want and Intellisense will list out the available events.
 
Upvote 0

Sagenut

Expert
Licensed User
Longtime User
how to load pictures auto zoom to (2.3,showPIC x,y)?
how to cpy function info by tips?

Private Sub ZoomImageView1_ZoomEvent(CurrentScale As Float, CenterX As Float, CenterY As Float)

txt1.Text= CurrentScale & ",xy=" & CenterX & "," & CenterY
End Sub
View attachment 171624
To my knowledge I think that a solution could be to take a screenshot, crop the selction to take only the text that you need and pass it to something like Google Translator or similar that can get the text from an image.
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
Check:
 
Upvote 0

Sagenut

Expert
Licensed User
Longtime User
I made some corrections to your project.
Check if this work.
If the comments are not clear enough make your questions about.
The Event in the code will be something like this
B4X:
Private Sub EventName_ZoomEvent (args As List)  ' <-- 加这行
    For Each o As Object In args
        Log(o)
    Next
End Sub

But please do not write in capital or extra textsize.
It can happen that me (or anyone else) does not understand correctly the question on first time.
With patience everything will come. 👍
 

Attachments

  • ZoomImageView2.zip
    3.6 KB · Views: 0
Last edited:
Upvote 0
Top