How to use pointerPressed method for particular image? - java-me

Hi Friends,
I have created one canvas form & on that i placed one image which is my button register. Now i am going to catch image touch events using pointerPressed method for only register image button. But how can i done this? can any one give me idea how to do this. How i can detect the user touches image of register using pointerPressed method. please help me friends.
Thanks

Working with CustomItem will provide your needs.

I have created one canvas form
Canvas or Form? these are totally different objects and handling pointer events would be totally different in Canvas vs Form.
given your mention of pointerPressed I suspect you're talking about Canvas right?
updated: For image drawn on Canvas (thanks for clarifying this btw), you need to know coordinates of the area it occupies, then you just need to check if x and y coordinates passed to in pointerPressed are within area occupied by your image (these are horizontal and vertical location where the pointer was pressed, relative to the Canvas - check the API docs)

Related

MergEXT MergZXing layer and barcode not reading

Just started working with this awesome external but have a couple of questions.
When the control is evoked, is it always the top layer or can I have a background transparent image on top of it so I can frame the control nicely?
Also, my testing seems to read most Barcodes but when it comes down to reading Barcodes on hard drives, the control does not want to decode those.... Too dense of bar code pattern?
I am very impressed thus far with the ease of use of your externals. Makes we want to code more for mobile devices!
an overlaying transparent image is not possible, as far as i know.
but couldnĀ“t you use
command mergZXingControlSetRect pLeft,pTop,pRight,pBottom
to define the rect of that scanner after creation
or
command mergZXingControlCreate pLeft,pTop,pRight,pBottom
to create the scanner control in the specified rect.
Set the rect smaller than the width and the height of the screen.
You could then use an underlying image, which is displayed outside of the scanner rect, to show the frame around scanner control. Did not test it myself, but i would assume that this should work.
Unfortunately the native controls in externals and the ones the engine provides are added as views on top of the LiveCode view. That means you can't intermingle LiveCode controls with them. One thing that some users have done is add a web view with a transparent background and a load a png image. If you create the barcode view first and the web view second then the web view will be on top.

Drawing a Rectangle that never dissapears

I have to draw a transparent square, that never disappears from the user's interface, by clicking to other windows the rectangle remains, only the windows/application content has to be shown behind.
I have thought of doing it with OpenGl or Flex or Canvas , but the problem is whenever I click on another window the programmed rectangle disappears .The rectangle has to act as a default image but has to be always at the foreground.
Do I have to mess with the operating system(Linux, Mac or Windows), by creating this image as default?
here is one example
http://i42.tinypic.com/15g3vxh.png
You can do that with Java pretty easy. See this link for code examples. If you got your transparent Image, you can use the setAlwaysOnTop(true); Method on the Object, and you are good to go. The only things that could get in front of that are other Applications that are using that method.

How do I make a circle move on events?

I'm pretty new to javafx so I'm trying to learn here so please be reasonable and don't dis away my question, I really appreciate any help at all, thanks!
I would like to know how I could move an object, let's say this circle on different events, like keypress or mouseclick, mousemove, whatever.
Circle circle = new Circle();
circle.setCenterX(100.0f);
circle.setCenterY(100.0f);
circle.setRadius(50.0f);
Do I need to use that KeyFrame thing I saw on the javafx site tutorial, or how does this work?
I would not have asked this here if I weren't feeling so lost, honestly.
So to make this clear: What is the code for moving objects that I created, by using events?
EDIT: By moving it I mean, press up key and it moves up by a few pixels, transform it maybe, with another key, or click somewhere on the scene and make it move there instantly or travel there with a certain speed. I don't have to redraw it like you need to with html5 canvas, I hope, right?
I don't have to redraw it like you need to with html5 canvas, I hope, right?
Not if you are using a standard JavaFX scene graph as opposed to a JavaFX canvas.
I would like to know how I could move an object, let's say this circle on different events, like keypress or mouseclick, mousemove, whatever
There are three ways to move a Shape:
You can adjust the shape's geometry (e.g. the centerX/centerY properties of a circle).
You can adjust the shape's layout (e.g. it's layoutX/layoutY properties).
You can adjust the shape's translation (e.g. it's translateX/translateY properties).
You can think of the layout as the home position for the object; i.e. where it should normally be in the context of it's parent group. You can think of it's translation transform as a temporary position for an object (often used when the object is being animated).
If you are using a layout pane such as a VBox or TilePane, then the layout pane will handle setting the layout co-ordinates of the child node for you. If you are using a simple Group or a plain Pane or Region, then you are responsible for setting the correct layout values for the child nodes.
To listen for events, set event handlers on Nodes or Scenes.
Here is a small sample app which demonstrates the above. It places the object to be moved inside a Group and modifies the position of the object within a Group in response to various events.

UIImageView doesn't obey it's content mode

I am designing an iOS App where there is a View controller with an embedded view controller in view at the bottom, and an image at the top. However, I'm having problems with the Image view. Without image view, everything is OK. When I put the image view, the image view doesn't fit in the image correctly. Here is how it looks in the interface builder (set to Scale to Fill):
When I run it in my iPod Touch (iOS 6), This is how it looks:
The image's aspect ratio is different than shown in the Interface Builder. Then, I try setting the image mode to Aspect Fill (which is actually the one I want):
This is exactly what I actually want, but when I run it, the image fills almost the entire screen:
Notice how my friend picker view controller is left behind the image view. The layout of the entire view controller is correct (embedded view controller is located correctly, notice at the point where the image ends in the last screenshot, it starts from J, meaning that it continues to the top behind the image), it's only the image view that is occupying too much space. I've tried different arrangements of the frame rectangle, and tried toggling Auto-layout of iOS 6. Neither did help. Am I missing an obvious point, or is it a bug with the layout system of iOS. (probably the second one, as WYSIWYG fails between Interface Builder and actual app) Are there any workarounds (other than cropping the portion of the image in Photoshop at the exact size that I want)?
Thanks,
Can.
UPDATE: A workaround that I've currently found is to put the image view in another view, and set the parent view's clip subviews property ticked. But the image view itself is still not behaving correctly, and even though this currently solved my problem, it is not a real solution, so any solution answers are welcome.

Find Pixel value in picture control to draw a graph

I am creating a project similar to task manager,
Now I want to draw a graph to that show cpu usage.
My problem is that I dont have any knowledge about painting in vc++,
but my idea is that I should first make a grid like in task manager but I dont have any pixel information,
So plese tell me how to find the pixel value if the Picture control.
Rather than trying to manipulate what's on screen what you need to do is a create a bitmap in memory using CBitmap::CreateCompatibleBitmap and BitBlt when Windows sends a WM_PAINT message.
This question looks at how to subclass a CStatic control (ie a picture control) to draw onto a dialog by handling WM_PAINT messages:
Handling WM_PAINT in a Subclassed CStatic Control
You just need to add the bitmap painting bit.

Resources