MCPcopy Create free account
hub / github.com/dillo-browser/dillo / click

Method click

src/html.cc:794–838  ·  view source on GitHub ↗

* Handle the "click" signal. */

Source from the content-addressed store, hash-verified

792 * Handle the "click" signal.
793 */
794bool DilloHtml::HtmlLinkReceiver::click (Widget *widget, int link, int img,
795 int x, int y, EventButton *event)
796{
797 BrowserWindow *bw = html->bw;
798
799 if ((img != -1) && (html->images->get(img)->image)) {
800 // clicked an image that has not already been loaded
801 if (event->button == 1){
802 // load all instances of this image
803 DilloUrl *pattern = html->images->get(img)->url;
804 html->loadImages(pattern);
805 return true;
806 }
807 }
808
809 if (link != -1) {
810 DilloUrl *url = html->links->get(link);
811 _MSG("clicked on URL %d: %s\n", link, a_Url_str (url));
812
813 Html_set_link_coordinates(html, link, x, y);
814
815 if (event->button == 1) {
816 a_UIcmd_open_url(bw, url);
817 } else if (event->button == 2) {
818 if (prefs.middle_click_opens_new_tab) {
819 int focus = prefs.focus_new_tab ? 1 : 0;
820 if (event->state == SHIFT_MASK) focus = !focus;
821 a_UIcmd_open_url_nt(bw, url, focus);
822 } else
823 a_UIcmd_open_url_nw(bw, url);
824 } else {
825 return false;
826 }
827
828 /* Change the link color to "visited" as visual feedback */
829 for (Widget *w = widget; w; w = w->getParent()) {
830 _MSG(" ->%s\n", w->getClassName());
831 if (w->instanceOf(dw::Textblock::CLASS_ID)) {
832 ((Textblock*)w)->changeLinkColor (link, html->visited_color);
833 break;
834 }
835 }
836 }
837 return true;
838}
839
840/**
841 * Initialize the stash buffer

Callers

nothing calls this directly

Calls 10

a_Url_strFunction · 0.85
a_UIcmd_open_urlFunction · 0.85
a_UIcmd_open_url_ntFunction · 0.85
a_UIcmd_open_url_nwFunction · 0.85
loadImagesMethod · 0.80
getClassNameMethod · 0.80
instanceOfMethod · 0.80
changeLinkColorMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected