onTouch event

Hi all

I want to make an area safe as an image and drawing to capture something.

Is there an API or something?

I need the event that could happen onTouch, onLeaveTouch or so... maybe he's the other?

Agreed. In fact, there are 2 years, I've written this example that uses canvas + touch events to produce a drawing "sketch pad".

https://github.com/BlackBerry/WebWorks-community-samples/tree/master/sketchPad

Tags: BlackBerry Developers

Similar Questions

  • movable control problems and onTouch event

    Hi guys

    In my last question, I posted about how can I make a movable control and it works fine, but now I have another question, when I drag a control and put on another control, which moves another control I guess that the elements are mixed with the OnTouch event.

    Here's an example I want to:

    But instead, the control move another decline of the level controls (when I drag control too close to a third party):

    I don't know how I can fix, I use a DockLayout, so that shouldn't happen.

    I use the following code on my movable controls:

    ImageView {
             id: watermark1
             imageSource: watermark.imageSource
             opacity: watermark.opacity
             translationX: 0
             translationY: 100
             attachedObjects: [
                 ImplicitAnimationController {
                     id: translationControllerY
                     propertyName: "translationY"
                 },
                 ImplicitAnimationController {
                                         id: translationControllerX
                                         propertyName: "translationX"
                 }
             ]
             property real iniX : 0;
             property real iniY : 0;
             property real posicionY: 100;
             property real posicionX: 0;
             onTouch: {
                 translationControllerY.enabled = false;
                 translationControllerX.enabled = false;
    
                 if (event.isDown()) {
                     iniX = event.windowX;
                     iniY = event.windowY;  
    
                 }
                 if (event.isMove()) {
                    guide.opacity = 0.6
                    guide1.opacity = 1.0
                    watermark1.translationX = posicionX + event.windowX - iniX;
                    watermark1.translationY = posicionY + event.windowY - iniY;
                    console.debug(iniX, iniY)
                    console.debug(watermark1.translationX + " and " + watermark1.translationY)
    
                 }
                 if (event.isUp()){
                     guide.opacity = 0
                     guide1.opacity = 0
                     posicionX = watermark1.translationX
                     posicionY = watermark1.translationY
                     console.debug("item left")
                 }
                 if (event.isCancel()){
                     guide.opacity = 0
                     guide1.opacity = 0
                     posicionX = watermark1.translationX
                     posicionY = watermark1.translationY
                     console.debug("Cancel)
                 }
               }
             }
    

    Hope you can help me

    Bravo and thank you!

    If you have this movement attached to each 'widget' code, then you will need to cover the event notecard for each other widget outside that you drag.

    The simplest but not the most elegant way is to set a global variable because everyone can see who puts a simple if statement around the code onTouch.

  • OnTouch event about to Listfield

    I did a listfield by extending a Vertical Manager where I add number of horizontal Manager. The HFM contains an image and a Text.Now of the thing is I want to get the index of the line when I click it. The problem is that for the first line, it gives me 0 which is correcnt, but for the 2nd it gives me 2 instead of 1, even for the 3rd it gives 4 instead of 2. Please help

    Just to avoid confusion, what you seem to have created is not a ListField, who is a completely different UI component that a series of HFMs added to an optimization of resources.

    You seem to be using getFieldIndex() on the optimization of resources.  If all you had added were the HFM, so I expect the index to go up by one. The fact that they are of 2 indicates that you have added something else, like a NullField.  So I would check your code to confirm the manager who you get the index of the fields of the and what you add to this Manager.

  • HELP in drawing and adding captions to picture

    Please forgive my English and my beginner skills. I am really new to QT, QPainter and graphics programming.

    I develop the application snap2chat.  And I badly need help with drawing and add captions to Images.

    I tried QPainter paint brushes in the picture and save it. But it's really slow. I also added onTouch event on the image and passed the localX and localY and this is the position that I also used for the QPainter to paint on and does not have the right position for painting too.

    and also the image GET bluish when I start painting.

    QImage theimage = QImage(imagePath);
    
        QPainter painter(&theimage);
        painter.setRenderHint(QPainter::Antialiasing, true);
        painter.setPen(QPen(Qt::transparent, 3, Qt::SolidLine, Qt::RoundCap)); // stroke
        painter.setBrush(QBrush(Qt::green, Qt::SolidPattern)); // fill
        painter.drawEllipse(x, y, 10, 10);
    
        //theimage.save(imagePath, "JPG"); // I also tried uncommenting this
    
        const bb::ImageData imageData = bb::ImageData::fromPixels(theimage.bits(), bb::PixelFormat::RGBX, theimage.width(), theimage.height(), theimage.bytesPerLine());
    
        m_image = bb::cascades::Image(imageData); // this is the image I show in the ImageView
    

    Also drawing with QPainter texts it blocks with the reason for the QFontDatabase. I saw a solution in another thread to add this line , but nothing helped.

    Any suggestions please?

    I didn't know he jumped a dialogue... the alternative is to write the screen to a bitmap image and then save it, works with 10.0 api and does not require a permission to screen capture or guest

    I wrote an example that shows how to do this.

    https://github.com/slashkyle/Cascades-samples/tree/master/CaptureThis

  • NavigationPane Query

    Hello

    I use a NavigationPane in my application. My main screen consists of headers and labels and labels have onTouch {} events that will grow to a specific page in the stack.

    As each page a WebView, I was wondering if it is possible to create a dynamic WebView? (so the actionBar is identical every time) and I don't have to create a new WebView on each page, and I'm a little confused by the WebStorage; I tried to give a key that caches all WebViews then a button to clear the cache.

    Furthermore, I leaned to create a button to increase/decrease the police size; I created this in JavaScript and named the file TextResize.js

    function resizeText(multiplier) {
        if (document.body.style.fontSize == "") {
            document.body.style.fontSize == "1.0em";
        }
        document.body.style.fontSize = parseFloat(document.body.style.fontSize) + (multiplier * 0.2) + "em";
    }
    

    I then imported in one of my pages QML

    import "TextResize.js" as TextResize
    
    actions: [
    ActionItem {
                title: "Increase Font Size"
                ActionBar.placement: ActionBarPlacement.InOverflow
    
                onTriggered: {
                    TextResize.resizeText(1)
                }
            },
            ActionItem {
                title: "Decrease Font Size"
                ActionBar.placement: ActionBarPlacement.InOverflow
    
                onTriggered: {
                    TextResize.resizeText(-1)
                }
            }
    ]
    

    Yet the buttons do not seem to do anything when the increase or decrease of the police in a WebView, so I was wondering if there is another way to increase or decrease the police in a WebView using ActionItems?

    Also, I use a MapView - with visibility set to false - and then, when the user clicks on "View map" (in the menu "more"), the plan would become visible. is it possible somehow that create dynamically - so that the card is always the same, except that it will be a different long and lat on each page or I create the MapView on each of my pages QML?

    Finally, I'm looking to create a page of settings - options for a clear/dark theme selector (coupled with a dialog box: to inform the user that they will have to restart the app) but I don't know where to start on this one here.

    Thanks in advance

    LOL, in fact there are four questions here are not here can you create 4 threads separated, thank you.

  • Can we open document from the hyperlink QML?

    Can we open document from the hyperlink qml?

    Label

    {

    "text:"Click here!

    "

    }

    I know that this problem has been resolved, but won't this is the solution.

    People, please stop using onTouch event on controls to manage the events of tap.

    To manage the tap, you must use gestureHandlers instead of onTouch

    gestureHandlers: [
                    TapHandler {
                        onTapped: {
                            // THIS CONTROL IS TAPPED AND NOT SIMPLY "TOUCHED". DO SOMETHING HERE
                        }
                    }
                ]
    

    If you treat your event on signal Notecard, you will eventually provide a poor user experience!

  • Touch events in Cascades/QML

    Hello everyone

    I'm "new" in this kind of things of Cascades and a lot is different from that of QtQuick on Symbian, that's why I have one, well two small questions:

    (1) how can I manage touch events. For example I want to design an element as a button, but without using the predefined one. Basically, it's a container with color and a label in it. And I want to give a basic animation, I'm searching for equal to onPressed and onReleased, two methods to change the background color, when the user presses the button and make it back to the default color, when it releases.

    (2) is there any kind of Qt Assistant for Cascades? I couldn't find the reference to assistance in line/API here, but it is so messed up my opinion and lack features such as research. In the best cases, this documentation is fully downloadable and usable offline.

    Hopefully, you can help me...

    Best regards

    Sebastian

    I worked today on a similar question. You can query the key like this event type:

    onTouch: {
        if (event.touchType == TouchType.Down) {
          //doStuff
        }
    }
    

    I used this to make a whole one button container, regardless of its content.

  • Parents and children Touch - event management

    I have a container with some controls.

    I want this is notecard to the container code to run only if no child control has handled the event onTouch.

    Is this possible?

    Thank you

    Jamie

    I solved it.

    Here's how...

    First of all, there are two touch events, I have now, I understand as follows:

    'touchCapture' is received in a container before the spread of children take place.

    'touch' is received in a container after the propagation takes place.

    I've added a property to the container like this:

    Boolean touchHandled property

    I added handlers for the touchCapture and the touch, like this:

    onTouchCapture: {}
    touchHandled = false
    }

    Notecard: {}
    If (! touchHandled) {}
    Manage you like...
    }
    }

    If a child control manages the key event, I the child touchHandled set to true. For example, in one of the children, I manage a TOP event. I have code like this (in children):

    Notecard: {}
    If (event.isUp ()) {}
    Do all that...

    touchHandled = true
    }
    }

    Mission accomplished. Comments are welcome...

    Jamie

  • How to receive events touch of legend in mapview bubble?

    Hello developers,
    I have been woking on a map-based application. I want to see the PIN to some place on click and click a pin it there otherwise pop up on available in OS bb10 and can also add our user interface customized for the legend label. I saw an example of custom mapview http://blackberry.github.io/Cascades-Samples/custommapview.html in which they created a container separated and shown that the container during the click on pin.but that the container is not ' receive events.so touch how should I get the Touch touch events? pls help developer friends...

    Thank you

    I just tested and the onTouch Manager works perfectly.

    I added the following code in the main container of the bubble component to change the color of the label (you will need to add the > string in the Label component to test).

        onTouch: {
            label.textStyle.color = Color.Red;
        }
    
  • QML: calculate the time interval between the touch events

    I create a custom button that is activated by a key event, in this way:

    Container {
        property bool pressed
        signal clicked...
        onTouch: {
            if (enabled && ! event.isMove()) {
                if (event.isUp() && pressed) clicked()
                pressed = event.isDown()
            }
        }
    }
    

    The problem with this approach is that if the user clicks the custom button several times in a short period of time the click signal is triggered several times too. This does not happen if I use a regular button or an ImageButton.

    I was thinking about getting the timestamp of the event and fire the only if clicked event grit touch after at least x milliseconds since the previous event. The DIF is that I couldn't find a way to calculate this difference in QML.

    Any suggestions?

    You could also follow the time of the last event with the Javascript date.

    lastTouched = new Date().valueOf();
    

    -Check if time has passed...

  • Management of the events of Cascades

    How do we consume the event top if onTouchEnter has been called? I have some of these containers on screen. When I'm in the State down on a container and I move to another, I get the event put on the newly selected container. Is it something I can call in onTouchEnter to ignore the next event?

    I was able to make it work in QML.

    Here's the QML which forms the basis of all my custom buttons:

    PanelButton.qml

    import bb.cascades 1.0
    
    Container {
        property variant pageToLoad: ""    property variant state: TouchEvent.Up
    
        id: panelBtn
        layout: DockLayout {
        }
    
        //the background image is 9 sliced and expands to the size of the button
        ImageView {
            layoutProperties: DockLayoutProperties {
                horizontalAlignment: HorizontalAlignment.Fill
                verticalAlignment: VerticalAlignment.Fill
            }
            id: "btnBG"
            imageSource: "asset:///ui/panel_up"
            scalingMethod: ScalingMethod.Fill
            minWidth: 60
            minHeight: 60
        }
    
         //
        onTouch: {
            //
            if (event.isUp () && panelBtn.state == TouchType.Down) {
                panelBtn.state = TouchType.Up;
                btnBG.imageSource = "asset:///ui/panel_up";
                root.navClick (pageToLoad);
            }
    
            //
            if (event.isDown ()) {
                btnBG.imageSource = "asset:///ui/panel_down";
                panelBtn.state = TouchType.Down;
            }
            else if(event.isCancel ())
            {
                btnBG.imageSource = "asset:///ui/panel_up";
                panelBtn.state = TouchType.Up;
            }
        }
    
        //
        onTouchExit: {
            btnBG.imageSource = "asset:///ui/panel_up";
            panelBtn.state = TouchType.Up;
        }
    
        //
        onTouchEnter: {
            btnBG.imageSource = "asset:///ui/panel_up";
            panelBtn.state = TouchType.Up;
        }
    }
    
  • Contact event in PRC management?

    I want to manage touch event on CPP and not qml.

    Redo exactly the same as the solution of http://supportforums.blackberry.com/t5/Native-Development/touch-does-not-fire-for-q10/td-p/3026980

    with no qml whatsoever.

    Touch the event indicates on the label.

    Click event displays on the console.

    applicationui.cpp:

    #include "applicationui.hpp"
    
    #include 
    #include 
    #include 
    #include 
    
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    
    using namespace bb::cascades;
    
    ApplicationUI::ApplicationUI() :
            QObject()
    {
        // prepare the localization
        m_pTranslator = new QTranslator(this);
        m_pLocaleHandler = new LocaleHandler(this);
    
        bool res = QObject::connect(m_pLocaleHandler, SIGNAL(systemLanguageChanged()), this, SLOT(onSystemLanguageChanged()));
        // This is only available in Debug builds
        Q_ASSERT(res);
        // Since the variable is not used in the app, this is added to avoid a
        // compiler warning
        Q_UNUSED(res);
    
        // initial load
        onSystemLanguageChanged();
    
        //Create Page
        Page *page = new Page();
    
        // Create Label
        label = new Label();
        label->setMultiline(true);
    
        // Connect Tap handler
        TapHandler *tapHandler = TapHandler::create()
            .onTapped(this, SLOT(onTappedHandler(bb::cascades::TapEvent*)));
    
        // Create Container, add Label and Gesture Handler to it and connect to touch event
        Container *container = Container::create()
            .layout(new DockLayout)
            .horizontal(HorizontalAlignment::Fill)
            .vertical(VerticalAlignment::Fill)
            .add(label)
            .addGestureHandler(tapHandler)
            .onTouch(this, SLOT(onTouch(bb::cascades::TouchEvent*)));
    
        // Add Container to Page
        page->setContent(container);
    
        // Set created root object as the application scene
        Application::instance()->setScene(page);
    }
    
    void ApplicationUI::onSystemLanguageChanged()
    {
        QCoreApplication::instance()->removeTranslator(m_pTranslator);
        // Initiate, load and install the application translation files.
        QString locale_string = QLocale().name();
        QString file_name = QString("TestContainer_%1").arg(locale_string);
        if (m_pTranslator->load(file_name, "app/native/qm")) {
            QCoreApplication::instance()->installTranslator(m_pTranslator);
        }
    }
    
    void ApplicationUI::onTouch(bb::cascades::TouchEvent* event){
        switch(event->touchType()) {
            case TouchType::Cancel: {
                addToLabel("TouchType: Cancel");
                break;
            }
            case TouchType::Down: {
                addToLabel("TouchType: Down");
                break;
            }
            case TouchType::Move: {
                addToLabel("TouchType: Move");
                break;
            }
            case TouchType::Up: {
                addToLabel("TouchType: Up");
                addToLabel("X: " + QString::number(event->windowX()) + "Y: " + QString::number(event->windowY()));
                break;
            }
            default: {
                addToLabel("UNDEFINED");
            }
        }
    }
    
    void ApplicationUI::onTappedHandler(bb::cascades::TapEvent* event) {
        qDebug() << "Tapped";
        qDebug() << "X:" << event->x() << "Y:" << event->y();
    }
    
    void ApplicationUI::addToLabel(QString text) {
        label->setText(text + "\n" + label->text());
    }
    

    applicationui. HPP:

    #ifndef ApplicationUI_HPP_
    #define ApplicationUI_HPP_
    
    #include 
    #include 
    #include 
    #include 
    
    namespace bb
    {
        namespace cascades
        {
            class LocaleHandler;
        }
    }
    
    class QTranslator;
    
    /*!
     * @brief Application UI object
     *
     * Use this object to create and init app UI, to create context objects, to register the new meta types etc.
     */
    class ApplicationUI : public QObject
    {
        Q_OBJECT
    public:
        ApplicationUI();
        virtual ~ApplicationUI() {}
    private slots:
        void onSystemLanguageChanged();
        void onTouch(bb::cascades::TouchEvent* event);
        void onTappedHandler(bb::cascades::TapEvent* event);
    private:
        void addToLabel(QString text);
    
        QTranslator* m_pTranslator;
        bb::cascades::LocaleHandler* m_pLocaleHandler;
    
        bb::cascades::Label* label;
    };
    
    #endif /* ApplicationUI_HPP_ */
    
  • Problem with slot onTouch in ImageView.

    When I do a count function to get the number of times a photo is affected.

    But when I touch picture just 1 time, but the show 2 function.

    I don't know what is happening. Help, please.

    Thank you.

    You can try this please? (in QML)

    onTouch: {
      if (event.isDown()) {
        // ...
      }
    }
    

    Here is a list of all key events:

    https://developer.BlackBerry.com/Cascades/reference/bb__cascades__touchevent.html#IsDown

    Slot machines and Q_INVOKABLE functions can be called from QML.

  • How to invite people to an event calendar with the new iOS 10?

    Before I updated to iOS of 10, I was able to create a calendar event with the apple iPhone built-in calendar and there is an option to 'invite' contacts him so they could add to their calendar. I can't find this option now after the new update. Where and how can I do this?

    Invite others to an event. You can invite people to an event, even if you're not the one who, on demand with Exchange and some other servers. Press an event, press on modify, then on the guests. Type the names, or tap to select the people to contact. If you don't want to be notified when someone refuses a meeting, go to settings > calendar, then disable view guest declines.

  • the iOS 10 not displaying calendar widget is not the events

    After the update to iOS 10.0.2, the calendar available on the lock screen widget does not always display the events. Nor the duration of the event or the event name appears, but a white widget with calendar color bar can be seen.

    This is not always the case, but very often. For ex, if you open the calendar application, then check this widget, event, but after that you lock the screen and check again, it would disappear.

    Hello jyothishureth,

    Thank you for using communities of Apple Support. It is my understanding from your iPhone Calendar widget still shows no events. I use my daily calendar to keep me organized. I can understand your concern. I'm happy to help you.

    If you haven't done so already, I recommend that you restart the phone. This can solve many unexpected behaviours. Follow the steps below:

    1. Press and hold the sleep/wake button until the Red slider appears.
    2. Drag the slider to turn off your device completely off.
    3. Once the device turns off, press and hold the sleep/wake button again until you see the Apple logo

    Restart your iPhone, iPad or iPod touch

    If the problem persists, try to remove the widget and adding it back on. Use the following steps:

    1. Right above the home, lock screen or Notification Centerscreen.
    2. Scroll down and tap on change.
    3. To add a Widget, press on . To remove a Widget, press on . To reorder your Widgets, touch and hold next to the apps and drag the in the desired order.
    4. Finally, tap done.

    Use Widgets on your iPhone, iPad and iPod touch

    Have a great day!

Maybe you are looking for

  • HP 2000: Hard drive short DST check - failure

    A ran a diagnostic equipment and received the message... ID of congestive M4UF88 - Q 6, 2847 - MFGJXG - 60WB03 product ID EOP73UA #ABL I have no idea what that means! Is my bread cell phone. I can't on my account admin, only one guest. I lose and it

  • Upgrading RAM on the C670D-115 Satellite

    What kind of ram I should buy to add two other GB on my computer ram for a C-satellite c670D-115?I use windows 7. (µ - Pro is AMD-E300) Thank you for choosing Kingston ram, Michel

  • Satellite Pro A300 - FN key works only with xp downgrade

    I just bought a Toshiba Satellite Pro A300 and downgraded the o/s to XP. There is a problem with the FN key on the keyboard, it does not work. I don't know if this has something to do with the downgrade xp? Any ideas please?

  • Password and forgotten Email

    Hi guys,. So basically I'm recovering an old Skype of mine, and I forgot what email I used to create it (because he had if long ago) and the password that I changed it to while someone was trying to hack. Is there a way that I can know what email I u

  • Cannot create map

    When I try to create a map with Photos, I have a spinner endless when I select a card and takes me to the display "choose the map theme. It is an empty view except for the top two menus (one with a spin at the last supper to the right) and below this