comparison Libs/DF/cooltip.lua @ 55:307f5af3ad02

- Framework update.
author Tercio
date Sat, 09 Dec 2017 11:49:01 -0200
parents 36b4d9559b69
children 7c0f819a85c6
comparison
equal deleted inserted replaced
54:def82fea66d4 55:307f5af3ad02
28 28
29 ---------------------------------------------------------------------- 29 ----------------------------------------------------------------------
30 --> Cooltip Startup 30 --> Cooltip Startup
31 ---------------------------------------------------------------------- 31 ----------------------------------------------------------------------
32 32
33 --> if a cooltip is already created with a higher version
33 if (_G.GameCooltip2 and _G.GameCooltip2.version >= version) then 34 if (_G.GameCooltip2 and _G.GameCooltip2.version >= version) then
34 return 35 return
35 end 36 end
36 37
37 --> Start Cooltip Table 38 --> initialize
38 local CoolTip = {version = version} 39 local CoolTip = {
40 version = version
41 }
39 _G.GameCooltip2 = CoolTip 42 _G.GameCooltip2 = CoolTip
40 43
41 --> Containers 44 --> containers
42 CoolTip.LeftTextTable = {} 45 CoolTip.LeftTextTable = {}
43 CoolTip.LeftTextTableSub = {} 46 CoolTip.LeftTextTableSub = {}
44 CoolTip.RightTextTable = {} 47 CoolTip.RightTextTable = {}
45 CoolTip.RightTextTableSub = {} 48 CoolTip.RightTextTableSub = {}
46 CoolTip.LeftIconTable = {} 49 CoolTip.LeftIconTable = {}
146 CoolTip.selected_anchor.top = 0 149 CoolTip.selected_anchor.top = 0
147 CoolTip.selected_anchor.bottom = 0 150 CoolTip.selected_anchor.bottom = 0
148 151
149 CoolTip._default_font = SharedMedia:Fetch ("font", "Friz Quadrata TT") 152 CoolTip._default_font = SharedMedia:Fetch ("font", "Friz Quadrata TT")
150 153
151 --> Create Frames 154 --> create frames
152 155
153 --> main frame 156 --> main frame
154 local frame1 157 local frame1
155 if (not GameCooltipFrame1) then 158 if (not GameCooltipFrame1) then
156 frame1 = CreateFrame ("Frame", "GameCooltipFrame1", UIParent, "DFCooltipMainFrameTemplate") 159 frame1 = CreateFrame ("Frame", "GameCooltipFrame1", UIParent, "DFCooltipMainFrameTemplate")
198 CoolTip.frame1 = frame1 201 CoolTip.frame1 = frame1
199 CoolTip.frame2 = frame2 202 CoolTip.frame2 = frame2
200 DF:FadeFrame (frame1, 0) 203 DF:FadeFrame (frame1, 0)
201 DF:FadeFrame (frame2, 0) 204 DF:FadeFrame (frame2, 0)
202 205
203 --> button containers 206 --> line container
204 frame1.Lines = {} 207 frame1.Lines = {}
205 frame2.Lines = {} 208 frame2.Lines = {}
206 209
207 ---------------------------------------------------------------------- 210 ----------------------------------------------------------------------
208 --> Title Function 211 --> Title Function
263 266
264 CoolTip.mouseOver = false 267 CoolTip.mouseOver = false
265 CoolTip.buttonClicked = false 268 CoolTip.buttonClicked = false
266 269
267 frame1:SetScript ("OnEnter", function (self) 270 frame1:SetScript ("OnEnter", function (self)
268 if (CoolTip.Type ~= 1 and CoolTip.Type ~= 2) then --> menu 271 --> is cooltip a menu?
272 if (CoolTip.Type ~= 1 and CoolTip.Type ~= 2) then
269 CoolTip.active = true 273 CoolTip.active = true
270 CoolTip.mouseOver = true 274 CoolTip.mouseOver = true
271 CoolTip.had_interaction = true 275 CoolTip.had_interaction = true
272 self:SetScript ("OnUpdate", nil) 276 self:SetScript ("OnUpdate", nil)
273 DF:FadeFrame (self, 0) 277 DF:FadeFrame (self, 0)
274 --rever 278
275 if (CoolTip.sub_menus) then 279 if (CoolTip.sub_menus) then
276 DF:FadeFrame (frame2, 0) 280 DF:FadeFrame (frame2, 0)
277 end 281 end
278 end 282 end
279 end) 283 end)
385 frame.Lines [index] = new_button 389 frame.Lines [index] = new_button
386 return new_button 390 return new_button
387 end 391 end
388 392
389 local OnEnterUpdateButton = function (self, elapsed) 393 local OnEnterUpdateButton = function (self, elapsed)
390 elapsedTime = elapsedTime+elapsed 394 elapsedTime = elapsedTime+elapsed
391 if (elapsedTime > 0.001) then 395 if (elapsedTime > 0.001) then
392 --> search key: ~onenterupdatemain 396 --> search key: ~onenterupdatemain
393 CoolTip:ShowSub (self.index) 397 CoolTip:ShowSub (self.index)
394 CoolTip.last_button = self.index 398 CoolTip.last_button = self.index
395 self:SetScript ("OnUpdate", nil) 399 self:SetScript ("OnUpdate", nil)
396 end 400 end
397 end 401 end
398 402
399 local OnLeaveUpdateButton = function (self, elapsed) 403 local OnLeaveUpdateButton = function (self, elapsed)
400 elapsedTime = elapsedTime+elapsed 404 elapsedTime = elapsedTime+elapsed
401 if (elapsedTime > 0.7) then 405 if (elapsedTime > 0.7) then
402 if (not CoolTip.active and not CoolTip.buttonClicked) then 406 if (not CoolTip.active and not CoolTip.buttonClicked) then
403 DF:FadeFrame (frame1, 1) 407 DF:FadeFrame (frame1, 1)
404 DF:FadeFrame (frame2, 1) 408 DF:FadeFrame (frame2, 1)
405 409
406 elseif (not CoolTip.active) then 410 elseif (not CoolTip.active) then
407 DF:FadeFrame (frame1, 1) 411 DF:FadeFrame (frame1, 1)
408 DF:FadeFrame (frame2, 1) 412 DF:FadeFrame (frame2, 1)
409 end 413 end
410 frame1:SetScript ("OnUpdate", nil) 414 frame1:SetScript ("OnUpdate", nil)
411 end 415 end
412 end 416 end
417
418 local OnEnterMainButton = function (self)
419 if (CoolTip.Type ~= 1 and CoolTip.Type ~= 2 and not self.isDiv) then
420 CoolTip.active = true
421 CoolTip.mouseOver = true
422 CoolTip.had_interaction = true
423
424 frame1:SetScript ("OnUpdate", nil)
425 frame2:SetScript ("OnUpdate", nil)
426
427 self.background:Show()
428
429 if (CoolTip.OptionsTable.IconBlendModeHover) then
430 self.leftIcon:SetBlendMode (CoolTip.OptionsTable.IconBlendModeHover)
431 else
432 self.leftIcon:SetBlendMode ("BLEND")
433 end
434
435 if (CoolTip.PopupFrameTable [self.index]) then
436 local on_enter, on_leave, param1, param2 = unpack (CoolTip.PopupFrameTable [self.index])
437 if (on_enter) then
438 xpcall (on_enter, geterrorhandler(), frame1, param1, param2)
439 end
440
441 elseif (CoolTip.IndexesSub [self.index] and CoolTip.IndexesSub [self.index] > 0) then
442 if (CoolTip.OptionsTable.SubMenuIsTooltip) then
443 CoolTip:ShowSub (self.index)
444 self.index = self.ID
445 else
446 if (CoolTip.last_button) then
447 CoolTip:ShowSub (CoolTip.last_button)
448 else
449 CoolTip:ShowSub (self.index)
450 end
451 elapsedTime = 0
452 self.index = self.ID
453 self:SetScript ("OnUpdate", OnEnterUpdateButton)
454 end
455
456 else
457 --hide second frame
458 DF:FadeFrame (frame2, 1)
459 CoolTip.last_button = nil
460 end
461 else
462 CoolTip.mouseOver = true
463 CoolTip.had_interaction = true
464 end
465 end
466
467 local OnLeaveMainButton = function (self)
468 if (CoolTip.Type ~= 1 and CoolTip.Type ~= 2 and not self.isDiv) then
469 CoolTip.active = false
470 CoolTip.mouseOver = false
471 self:SetScript ("OnUpdate", nil)
472
473 self.background:Hide()
474
475 if (CoolTip.OptionsTable.IconBlendMode) then
476 self.leftIcon:SetBlendMode (CoolTip.OptionsTable.IconBlendMode)
477 self.rightIcon:SetBlendMode (CoolTip.OptionsTable.IconBlendMode)
478 else
479 self.leftIcon:SetBlendMode ("BLEND")
480 self.rightIcon:SetBlendMode ("BLEND")
481 end
482
483 if (CoolTip.PopupFrameTable [self.index]) then
484 local on_enter, on_leave, param1, param2 = unpack (CoolTip.PopupFrameTable [self.index])
485 if (on_leave) then
486 xpcall (on_leave, geterrorhandler(), frame1, param1, param2)
487 end
488 end
489
490 elapsedTime = 0
491 frame1:SetScript ("OnUpdate", OnLeaveUpdateButton)
492 else
493 CoolTip.active = false
494 elapsedTime = 0
495 frame1:SetScript ("OnUpdate", OnLeaveUpdateButton)
496 CoolTip.mouseOver = false
497 end
498 end
413 499
414 function CoolTip:NewMainButton (i) 500 function CoolTip:NewMainButton (i)
415 local botao = CoolTip:CreateButton (i, frame1, "GameCooltipMainButton"..i) 501 local newButton = CoolTip:CreateButton (i, frame1, "GameCooltipMainButton"..i)
416 502
417 --> serach key: ~onenter 503 --> serach key: ~onenter
418 botao:SetScript ("OnEnter", function() 504 newButton.ID = i
419 if (CoolTip.Type ~= 1 and CoolTip.Type ~= 2 and not botao.isDiv) then 505 newButton:SetScript ("OnEnter", OnEnterMainButton)
420 CoolTip.active = true 506 newButton:SetScript ("OnLeave", OnLeaveMainButton)
421 CoolTip.mouseOver = true 507
422 CoolTip.had_interaction = true 508 return newButton
423 509 end
424 frame1:SetScript ("OnUpdate", nil) 510
425 frame2:SetScript ("OnUpdate", nil) 511 --> buttons for the secondary frame
426
427 botao.background:Show()
428
429 if (CoolTip.OptionsTable.IconBlendModeHover) then
430 botao.leftIcon:SetBlendMode (CoolTip.OptionsTable.IconBlendModeHover)
431 else
432 botao.leftIcon:SetBlendMode ("BLEND")
433 end
434
435 if (CoolTip.PopupFrameTable [botao.index]) then
436 local on_enter, on_leave, param1, param2 = unpack (CoolTip.PopupFrameTable [botao.index])
437 if (on_enter) then
438 xpcall (on_enter, geterrorhandler(), frame1, param1, param2)
439 end
440
441 elseif (CoolTip.IndexesSub [botao.index] and CoolTip.IndexesSub [botao.index] > 0) then
442 if (CoolTip.OptionsTable.SubMenuIsTooltip) then
443 CoolTip:ShowSub (botao.index)
444 botao.index = i
445 else
446 if (CoolTip.last_button) then
447 CoolTip:ShowSub (CoolTip.last_button)
448 else
449 CoolTip:ShowSub (botao.index)
450 end
451 elapsedTime = 0
452 botao.index = i
453 botao:SetScript ("OnUpdate", OnEnterUpdateButton)
454 end
455
456 else
457 --hide second frame
458 DF:FadeFrame (frame2, 1)
459 CoolTip.last_button = nil
460 end
461 else
462 CoolTip.mouseOver = true
463 CoolTip.had_interaction = true
464 end
465 end)
466
467 botao:SetScript ("OnLeave", function()
468 if (CoolTip.Type ~= 1 and CoolTip.Type ~= 2 and not botao.isDiv) then
469 CoolTip.active = false
470 CoolTip.mouseOver = false
471 botao:SetScript ("OnUpdate", nil)
472
473 botao.background:Hide()
474
475 if (CoolTip.OptionsTable.IconBlendMode) then
476 botao.leftIcon:SetBlendMode (CoolTip.OptionsTable.IconBlendMode)
477 botao.rightIcon:SetBlendMode (CoolTip.OptionsTable.IconBlendMode)
478 else
479 botao.leftIcon:SetBlendMode ("BLEND")
480 botao.rightIcon:SetBlendMode ("BLEND")
481 end
482
483 if (CoolTip.PopupFrameTable [botao.index]) then
484 local on_enter, on_leave, param1, param2 = unpack (CoolTip.PopupFrameTable [botao.index])
485 if (on_leave) then
486 xpcall (on_leave, geterrorhandler(), frame1, param1, param2)
487 end
488 end
489
490 elapsedTime = 0
491 frame1:SetScript ("OnUpdate", OnLeaveUpdateButton)
492 --CoolTip:HideSub (i)
493 else
494 CoolTip.active = false
495 elapsedTime = 0
496 frame1:SetScript ("OnUpdate", OnLeaveUpdateButton)
497 CoolTip.mouseOver = false
498 end
499 end)
500
501 return botao
502 end
503 512
504 local OnLeaveUpdateButtonSec = function (self, elapsed) 513 local OnLeaveUpdateButtonSec = function (self, elapsed)
505 elapsedTime = elapsedTime+elapsed 514 elapsedTime = elapsedTime+elapsed
506 if (elapsedTime > 0.7) then 515 if (elapsedTime > 0.7) then
507 if (not CoolTip.active and not CoolTip.buttonClicked) then 516 if (not CoolTip.active and not CoolTip.buttonClicked) then
508 DF:FadeFrame (frame1, 1) 517 DF:FadeFrame (frame1, 1)
509 DF:FadeFrame (frame2, 1) 518 DF:FadeFrame (frame2, 1)
510 elseif (not CoolTip.active) then 519 elseif (not CoolTip.active) then
511 DF:FadeFrame (frame1, 1) 520 DF:FadeFrame (frame1, 1)
512 DF:FadeFrame (frame2, 1) 521 DF:FadeFrame (frame2, 1)
513 end 522 end
514 frame2:SetScript ("OnUpdate", nil) 523 frame2:SetScript ("OnUpdate", nil)
515 end 524 end
516 end 525 end
526
527 local OnEnterSecondaryButton = function (self)
528 if (CoolTip.OptionsTable.SubMenuIsTooltip) then
529 return CoolTip:Close()
530 end
531 if (CoolTip.Type ~= 1 and CoolTip.Type ~= 2 and not self.isDiv) then
532 CoolTip.active = true
533 CoolTip.mouseOver = true
534 CoolTip.had_interaction = true
535
536 self.background:Show()
537
538 if (CoolTip.OptionsTable.IconBlendModeHover) then
539 self.leftIcon:SetBlendMode (CoolTip.OptionsTable.IconBlendModeHover)
540 else
541 self.leftIcon:SetBlendMode ("BLEND")
542 end
543
544 frame1:SetScript ("OnUpdate", nil)
545 frame2:SetScript ("OnUpdate", nil)
546
547 DF:FadeFrame (frame1, 0)
548 DF:FadeFrame (frame2, 0)
549 else
550 CoolTip.mouseOver = true
551 CoolTip.had_interaction = true
552 end
553 end
554
555 local OnLeaveSecondaryButton = function (self)
556 if (CoolTip.Type ~= 1 and CoolTip.Type ~= 2) then
557 CoolTip.active = false
558 CoolTip.mouseOver = false
559
560 self.background:Hide()
561
562 if (CoolTip.OptionsTable.IconBlendMode) then
563 self.leftIcon:SetBlendMode (CoolTip.OptionsTable.IconBlendMode)
564 self.rightIcon:SetBlendMode (CoolTip.OptionsTable.IconBlendMode)
565 else
566 self.leftIcon:SetBlendMode ("BLEND")
567 self.rightIcon:SetBlendMode ("BLEND")
568 end
569
570 elapsedTime = 0
571 frame2:SetScript ("OnUpdate", OnLeaveUpdateButtonSec)
572 else
573 CoolTip.active = false
574 CoolTip.mouseOver = false
575 elapsedTime = 0
576 frame2:SetScript ("OnUpdate", OnLeaveUpdateButtonSec)
577 end
578 end
517 579
518 function CoolTip:NewSecondaryButton (i) 580 function CoolTip:NewSecondaryButton (i)
519 local botao = CoolTip:CreateButton (i, frame2, "GameCooltipSecButton"..i) 581 local newButton = CoolTip:CreateButton (i, frame2, "GameCooltipSecButton"..i)
520 582
521 botao:SetScript ("OnEnter", function() 583 newButton.ID = i
522 if (CoolTip.OptionsTable.SubMenuIsTooltip) then 584 newButton:SetScript ("OnEnter", OnEnterSecondaryButton)
523 return CoolTip:Close() 585 newButton:SetScript ("OnLeave", OnLeaveSecondaryButton)
524 end 586
525 if (CoolTip.Type ~= 1 and CoolTip.Type ~= 2 and not botao.isDiv) then 587 return newButton
526 CoolTip.active = true
527 CoolTip.mouseOver = true
528 CoolTip.had_interaction = true
529
530 botao.background:Show()
531
532 if (CoolTip.OptionsTable.IconBlendModeHover) then
533 botao.leftIcon:SetBlendMode (CoolTip.OptionsTable.IconBlendModeHover)
534 else
535 botao.leftIcon:SetBlendMode ("BLEND")
536 end
537
538 frame1:SetScript ("OnUpdate", nil)
539 frame2:SetScript ("OnUpdate", nil)
540
541 DF:FadeFrame (frame1, 0)
542 DF:FadeFrame (frame2, 0)
543 else
544 CoolTip.mouseOver = true
545 CoolTip.had_interaction = true
546 end
547 end)
548
549 botao:SetScript ("OnLeave", function()
550 if (CoolTip.Type ~= 1 and CoolTip.Type ~= 2) then
551 CoolTip.active = false
552 CoolTip.mouseOver = false
553
554 botao.background:Hide()
555
556 if (CoolTip.OptionsTable.IconBlendMode) then
557 botao.leftIcon:SetBlendMode (CoolTip.OptionsTable.IconBlendMode)
558 botao.rightIcon:SetBlendMode (CoolTip.OptionsTable.IconBlendMode)
559 else
560 botao.leftIcon:SetBlendMode ("BLEND")
561 botao.rightIcon:SetBlendMode ("BLEND")
562 end
563
564 elapsedTime = 0
565 frame2:SetScript ("OnUpdate", OnLeaveUpdateButtonSec)
566 else
567 CoolTip.active = false
568 CoolTip.mouseOver = false
569 elapsedTime = 0
570 frame2:SetScript ("OnUpdate", OnLeaveUpdateButtonSec)
571 end
572 end)
573
574 return botao
575 end 588 end
576 589
577 ---------------------------------------------------------------------- 590 ----------------------------------------------------------------------
578 --> Button Click Functions 591 --> Button Click Functions
579 ---------------------------------------------------------------------- 592 ----------------------------------------------------------------------
613 frame.selectedBottom:SetPoint ("bottomright", button, "bottomright", right-1, bottom) -- 626 frame.selectedBottom:SetPoint ("bottomright", button, "bottomright", right-1, bottom) --
614 627
615 CoolTip:ShowSelectedTexture (frame) 628 CoolTip:ShowSelectedTexture (frame)
616 end 629 end
617 630
618 local OnClickFunctionButtonPrincipal = function (self, button) 631 local OnClickFunctionMainButton = function (self, button)
619 if (CoolTip.IndexesSub [self.index] and CoolTip.IndexesSub [self.index] > 0) then 632 if (CoolTip.IndexesSub [self.index] and CoolTip.IndexesSub [self.index] > 0) then
620 CoolTip:ShowSub (self.index) 633 CoolTip:ShowSub (self.index)
621 CoolTip.last_button = self.index 634 CoolTip.last_button = self.index
622 end 635 end
623 636
624 CoolTip.buttonClicked = true 637 CoolTip.buttonClicked = true
625 CoolTip:SetSelectedAnchor (frame1, self) 638 CoolTip:SetSelectedAnchor (frame1, self)
626 639
627 if (not CoolTip.OptionsTable.NoLastSelectedBar) then 640 if (not CoolTip.OptionsTable.NoLastSelectedBar) then
628 CoolTip:ShowSelectedTexture (frame1) 641 CoolTip:ShowSelectedTexture (frame1)
629 642 end
630 end 643 CoolTip.SelectedIndexMain = self.index
631 CoolTip.SelectedIndexMain = self.index 644
632 645 if (CoolTip.FunctionsTableMain [self.index]) then
633 if (CoolTip.FunctionsTableMain [self.index]) then 646 local parameterTable = CoolTip.ParametersTableMain [self.index]
634 local parameterTable = CoolTip.ParametersTableMain [self.index] 647 local func = CoolTip.FunctionsTableMain [self.index]
635 CoolTip.FunctionsTableMain [self.index] (_, CoolTip.FixedValue, parameterTable [1], parameterTable [2], parameterTable [3], button) 648 --> passing nil as the first parameter was a design mistake
636 end 649 --CoolTip.FunctionsTableMain [self.index] (_, CoolTip.FixedValue, parameterTable [1], parameterTable [2], parameterTable [3], button)
637 end 650 local okay, errortext = pcall (func, nil, CoolTip.FixedValue, parameterTable [1], parameterTable [2], parameterTable [3], button)
638 651 if (not okay) then
639 local OnClickFunctionButtonSecundario = function (self, button) 652 print ("Cooltip OnClick Error:", errortext)
640 CoolTip.buttonClicked = true 653 end
641 654 end
642 CoolTip:SetSelectedAnchor (frame2, self) 655 end
643 656
644 if (CoolTip.FunctionsTableSub [self.mainIndex] and CoolTip.FunctionsTableSub [self.mainIndex] [self.index]) then 657 local OnClickFunctionSecondaryButton = function (self, button)
645 local parameterTable = CoolTip.ParametersTableSub [self.mainIndex] [self.index] 658 CoolTip.buttonClicked = true
646 CoolTip.FunctionsTableSub [self.mainIndex] [self.index] (_, CoolTip.FixedValue, parameterTable [1], parameterTable [2], parameterTable [3], button) 659
647 end 660 CoolTip:SetSelectedAnchor (frame2, self)
648 661
649 local botao_p = frame1.Lines [self.mainIndex] 662 if (CoolTip.FunctionsTableSub [self.mainIndex] and CoolTip.FunctionsTableSub [self.mainIndex] [self.index]) then
650 CoolTip:SetSelectedAnchor (frame1, botao_p) 663 local parameterTable = CoolTip.ParametersTableSub [self.mainIndex] [self.index]
651 664 local func = CoolTip.FunctionsTableSub [self.mainIndex] [self.index]
652 if (not CoolTip.OptionsTable.NoLastSelectedBar) then 665 --CoolTip.FunctionsTableSub [self.mainIndex] [self.index] (_, CoolTip.FixedValue, parameterTable [1], parameterTable [2], parameterTable [3], button)
653 CoolTip:ShowSelectedTexture (frame1) 666 local okay, errortext = pcall (func, nil, CoolTip.FixedValue, parameterTable [1], parameterTable [2], parameterTable [3], button)
654 end 667 if (not okay) then
655 668 print ("Cooltip OnClick Error:", errortext)
656 CoolTip.SelectedIndexMain = self.mainIndex 669 end
657 CoolTip.SelectedIndexSec [self.mainIndex] = self.index 670 end
658 671
659 end 672 local botao_p = frame1.Lines [self.mainIndex]
673 CoolTip:SetSelectedAnchor (frame1, botao_p)
674
675 if (not CoolTip.OptionsTable.NoLastSelectedBar) then
676 CoolTip:ShowSelectedTexture (frame1)
677 end
678
679 CoolTip.SelectedIndexMain = self.mainIndex
680 CoolTip.SelectedIndexSec [self.mainIndex] = self.index
681 end
682
683
684 --> format functions
660 685
661 function CoolTip:TextAndIcon (index, frame, menuButton, leftTextTable, rightTextTable, leftIconTable, rightIconTable, isSub) 686 function CoolTip:TextAndIcon (index, frame, menuButton, leftTextTable, rightTextTable, leftIconTable, rightIconTable, isSub)
662
663 --> reset width 687 --> reset width
664 menuButton.leftText:SetWidth (0) 688 menuButton.leftText:SetWidth (0)
665 menuButton.leftText:SetHeight (0) 689 menuButton.leftText:SetHeight (0)
666 menuButton.rightText:SetWidth (0) 690 menuButton.rightText:SetWidth (0)
667 menuButton.rightText:SetHeight (0) 691 menuButton.rightText:SetHeight (0)
1008 frame1.w = stringWidth 1032 frame1.w = stringWidth
1009 end 1033 end
1010 end 1034 end
1011 1035
1012 --> register click function 1036 --> register click function
1013 menuButton:SetScript ("OnClick", OnClickFunctionButtonPrincipal) 1037 menuButton:SetScript ("OnClick", OnClickFunctionMainButton)
1014 menuButton:Show() 1038 menuButton:Show()
1015 end 1039 end
1016 1040
1017 function CoolTip:SetupSecondaryButton (menuButton, index, mainMenuIndex) 1041 function CoolTip:SetupSecondaryButton (menuButton, index, mainMenuIndex)
1018 1042
1042 local stringWidth = menuButton.leftText:GetStringWidth() + menuButton.rightText:GetStringWidth() + menuButton.leftIcon:GetWidth() + menuButton.rightIcon:GetWidth() 1066 local stringWidth = menuButton.leftText:GetStringWidth() + menuButton.rightText:GetStringWidth() + menuButton.leftIcon:GetWidth() + menuButton.rightIcon:GetWidth()
1043 if (stringWidth > frame2.w) then 1067 if (stringWidth > frame2.w) then
1044 frame2.w = stringWidth 1068 frame2.w = stringWidth
1045 end 1069 end
1046 1070
1047 menuButton:SetScript ("OnClick", OnClickFunctionButtonSecundario) 1071 menuButton:SetScript ("OnClick", OnClickFunctionSecondaryButton)
1048 menuButton:Show() 1072 menuButton:Show()
1049 1073
1050 return true 1074 return true
1051 end 1075 end
1052 1076