views:

402

answers:

4

I plan on appending some comments onto a text, to do that, first, I need the concerned text to act like a button for me to launch a popup, which in turn shows the comment. For that to happen, I need to make that concerned text to act like a button in GWT, but due to some aesthetic reasons I don't want it to look like a normal GWT Button, instead, I prefer it to look like any normal HTML hyper-link, which upon clicking it, acts exactly like a GWT Button which in turn showing the comment in the pop up. So is there a way to make a GWT Button appear more like a html hyper-link? Or, at the minimum, would it be possible to convert the concerned text to .JPG for it to be inserted into a Image Button in GWT?

A: 

Now, I'm not intimately familiar with GWT, but presumably the way the GWT button works is that it fires an event that shows the popup (actually I'm fairly certain this is how it's done).

If you dig a little in the GWT button code you should not have any problems of attaching a similar event-handlar to a normal <a>.

adamse
I want to modify the functionality of the GWT button via Java Code present in the class; NOT via editing the JavaScript code
Catfish
[UPDATE] Are you saying me to edit the CSS file? For me to trace the button class and to re-edit it to make it look like a hyper link
Catfish
What I understand that you're looking to do is to make a simple hyper-link have the same behaviour as a GWT button. Are you certain that this doesn't already exist? This is what I'm suggesting you do.
adamse
@adamse Since this project is on the preliminary stages, I'm currently just researching to test weather the current APIs are capable of it. So, yes, it might be that such a feature *might* exist, but I DON"T want it to be done via editing the .CSS file. Nonetheless I'm still wandering through the GWT docs for me to find any proper solution.
Catfish
I'm not suggesting that you should edit the css, I'm saying that it is possible for a simple anchor to have the same side effects as the GWT button. The GWT toolkit probably provides you with methods of attaching certain behaviour to anchor tags as well as GWT buttons. (Also you can't really expect any framework to do exactly what you want without any fiddling if you didn't write it yourself)
adamse
A: 

I'd never work with GWT but when you have something on a webpage, you can change the facde of control with CSS in a manner which nobody can guess what you used.

I suggest to use following css code block, and tell me was it good for you or not

#GWTButtonToLinkConverter
{
backgound-color: Transparent;
border: 0px;
border-collapse: collapse;
color: blue;
text-decoration: underline;
padding: 0px;
margin : 0px;
}
Nasser Hadjloo
Wayyy too much overhead for me to edit the css file, I plan on making a bot, so if there are -- like -- 5 five browsers out there, then, 5 different versions need to be addressed to by the bot -- rather -- make it simple and add some sort of 'custom' version of GWT Button -- or -- like I mentioned in the question, convert the to-be hyper link text to .JPEG file and place that .JPEG file into the GWT PushButton Object.
Catfish
+2  A: 

What you are probably looking for is an Anchor (heh, that was straightforward ;)). It implements the HasClickHandlers interface, so you can add a ClickHandler like such:

Anchor a = new Anchor("This is some text", false); // Set to true if the text contains HTML tags
a.addClickHandler(new ClickHandler() {
    onClick(ClickEvent event) {
        //Do some stuff
    }
});

Update:
A different solution is to use a FocusPanel - the advantage is that FocusPanel is a SimplePanel, meaning you can put another panel in it, which should make it easier to put other GWT Widgets in it (in case you wanted something more than just plain text in the clickable area - of course you can put any HTML in the Anchor, but my way is less 'hacky' IMHO).

HorizontalPanel hPanel = new HorizontalPanel();
hPanel.add(new Image("images/img.png"));
hPanel.add(new Label("Some text"));

FocusPanel focusPanel = new FocusPanel(hPanel);
focusPanel.addClickHandler(new ClickHandler() {
    onClick(ClickEvent event) {
        //Event fired when clicked anywhere in the hPanel - meaning the image and label
        //Do some stuff, maybe show a PopupPanel
    }
});

BTW, if you need a popup, check out the PopupPanel widget.

Igor Klimer
@Igor Klimer Yup, that the object which I was already planing on using as the pop-up object
Catfish
A: 

hello friends,

i m facing the problem of how to convert the text into image and paste it on RichTextArea. plz help me !!!

thanks in advance!

kavita sharma